Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: runtime/vm/object.cc

Issue 10784020: Revert fix for type checking of void type, because some top level tests fail. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/heap_test.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 // Type S is specified by this class parameterized with 'type_arguments', and 1775 // Type S is specified by this class parameterized with 'type_arguments', and
1776 // type T by class 'other' parameterized with 'other_type_arguments'. 1776 // type T by class 'other' parameterized with 'other_type_arguments'.
1777 // This class and class 'other' do not need to be finalized, however, they must 1777 // This class and class 'other' do not need to be finalized, however, they must
1778 // be resolved as well as their interfaces. 1778 // be resolved as well as their interfaces.
1779 bool Class::TypeTest( 1779 bool Class::TypeTest(
1780 TypeTestKind test_kind, 1780 TypeTestKind test_kind,
1781 const AbstractTypeArguments& type_arguments, 1781 const AbstractTypeArguments& type_arguments,
1782 const Class& other, 1782 const Class& other,
1783 const AbstractTypeArguments& other_type_arguments, 1783 const AbstractTypeArguments& other_type_arguments,
1784 Error* malformed_error) const { 1784 Error* malformed_error) const {
1785 ASSERT(!IsVoidClass());
1786 // Check for DynamicType. 1785 // Check for DynamicType.
1787 // Each occurrence of DynamicType in type T is interpreted as the Dynamic 1786 // Each occurrence of DynamicType in type T is interpreted as the Dynamic
1788 // type, a supertype of all types. 1787 // type, a supertype of all types.
1789 if (other.IsDynamicClass()) { 1788 if (other.IsDynamicClass()) {
1790 return true; 1789 return true;
1791 } 1790 }
1792 // In the case of a subtype test, each occurrence of DynamicType in type S is 1791 // In the case of a subtype test, each occurrence of DynamicType in type S is
1793 // interpreted as the bottom type, a subtype of all types. 1792 // interpreted as the bottom type, a subtype of all types.
1794 if (IsDynamicClass()) { 1793 if (IsDynamicClass()) {
1795 return test_kind == kIsSubtypeOf; 1794 return test_kind == kIsSubtypeOf;
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2346 } 2345 }
2347 2346
2348 2347
2349 RawAbstractType* AbstractType::Canonicalize() const { 2348 RawAbstractType* AbstractType::Canonicalize() const {
2350 // AbstractType is an abstract class. 2349 // AbstractType is an abstract class.
2351 UNREACHABLE(); 2350 UNREACHABLE();
2352 return NULL; 2351 return NULL;
2353 } 2352 }
2354 2353
2355 2354
2356 // TODO(regis): Investigate if we can safely map internal integer types (Smi,
2357 // Mint, and Bigint) to 'int' and internal String types (OneByteString, etc...)
2358 // to 'String' here. It may be too early. Also consider the upcoming type()
2359 // method.
2360 RawString* AbstractType::Name() const { 2355 RawString* AbstractType::Name() const {
2361 // If the type is still being finalized, we may be reporting an error about 2356 // If the type is still being finalized, we may be reporting an error about
2362 // an illformed type, so proceed with caution. 2357 // an illformed type, so proceed with caution.
2363 const AbstractTypeArguments& args = 2358 const AbstractTypeArguments& args =
2364 AbstractTypeArguments::Handle(arguments()); 2359 AbstractTypeArguments::Handle(arguments());
2365 const intptr_t num_args = args.IsNull() ? 0 : args.Length(); 2360 const intptr_t num_args = args.IsNull() ? 0 : args.Length();
2366 String& class_name = String::Handle(); 2361 String& class_name = String::Handle();
2367 intptr_t first_type_param_index; 2362 intptr_t first_type_param_index;
2368 intptr_t num_type_params; // Number of type parameters to print. 2363 intptr_t num_type_params; // Number of type parameters to print.
2369 if (HasResolvedTypeClass()) { 2364 if (HasResolvedTypeClass()) {
(...skipping 5287 matching lines...) Expand 10 before | Expand all | Expand 10 after
7657 ASSERT(field_offset != Class::kNoTypeArguments); 7652 ASSERT(field_offset != Class::kNoTypeArguments);
7658 *FieldAddrAtOffset(field_offset) = value.raw(); 7653 *FieldAddrAtOffset(field_offset) = value.raw();
7659 } 7654 }
7660 7655
7661 7656
7662 bool Instance::IsInstanceOf(const AbstractType& other, 7657 bool Instance::IsInstanceOf(const AbstractType& other,
7663 const AbstractTypeArguments& other_instantiator, 7658 const AbstractTypeArguments& other_instantiator,
7664 Error* malformed_error) const { 7659 Error* malformed_error) const {
7665 ASSERT(other.IsFinalized()); 7660 ASSERT(other.IsFinalized());
7666 ASSERT(!other.IsDynamicType()); 7661 ASSERT(!other.IsDynamicType());
7662 ASSERT(!other.IsVoidType());
7667 ASSERT(!other.IsMalformed()); 7663 ASSERT(!other.IsMalformed());
7668 if (IsNull()) { 7664 if (IsNull()) {
7669 // The null instance can be returned from a void function.
7670 if (other.IsVoidType()) {
7671 return true;
7672 }
7673 // Otherwise, null is only an instance of Object and of Dynamic.
7674 // It is not necessary to fully instantiate the other type for this test.
7675 Class& other_class = Class::Handle(); 7665 Class& other_class = Class::Handle();
7676 if (other.IsTypeParameter()) { 7666 if (other.IsTypeParameter()) {
7677 if (other_instantiator.IsNull()) { 7667 if (other_instantiator.IsNull()) {
7678 return true; // Other type is uninstantiated, i.e. Dynamic. 7668 return true; // Other type is uninstantiated, i.e. Dynamic.
7679 } 7669 }
7680 const TypeParameter& other_type_param = TypeParameter::Cast(other); 7670 const TypeParameter& other_type_param = TypeParameter::Cast(other);
7681 const AbstractType& instantiated_other = AbstractType::Handle( 7671 const AbstractType& instantiated_other = AbstractType::Handle(
7682 other_instantiator.TypeAt(other_type_param.index())); 7672 other_instantiator.TypeAt(other_type_param.index()));
7683 ASSERT(instantiated_other.IsInstantiated()); 7673 ASSERT(instantiated_other.IsInstantiated());
7684 other_class = instantiated_other.type_class(); 7674 other_class = instantiated_other.type_class();
7685 } else { 7675 } else {
7686 other_class = other.type_class(); 7676 other_class = other.type_class();
7687 } 7677 }
7688 return other_class.IsObjectClass() || other_class.IsDynamicClass(); 7678 return other_class.IsObjectClass() || other_class.IsDynamicClass();
7689 } 7679 }
7690 if (other.IsVoidType()) {
7691 return false;
7692 }
7693 const Class& cls = Class::Handle(clazz()); 7680 const Class& cls = Class::Handle(clazz());
7694 // We must not encounter Object::sentinel() or Object::transition_sentinel(), 7681 // We must not encounter Object::sentinel() or Object::transition_sentinel(),
7695 // both instances of class NullClass, but not instance Object::null(). 7682 // both instances of class NullClass, but not instance Object::null().
7696 ASSERT(!cls.IsNullClass()); 7683 ASSERT(!cls.IsNullClass());
7697 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); 7684 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
7698 const intptr_t num_type_arguments = cls.NumTypeArguments(); 7685 const intptr_t num_type_arguments = cls.NumTypeArguments();
7699 if (num_type_arguments > 0) { 7686 if (num_type_arguments > 0) {
7700 type_arguments = GetTypeArguments(); 7687 type_arguments = GetTypeArguments();
7701 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { 7688 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) {
7702 type_arguments = type_arguments.Canonicalize(); 7689 type_arguments = type_arguments.Canonicalize();
(...skipping 3097 matching lines...) Expand 10 before | Expand all | Expand 10 after
10800 const String& str = String::Handle(pattern()); 10787 const String& str = String::Handle(pattern());
10801 const char* format = "JSRegExp: pattern=%s flags=%s"; 10788 const char* format = "JSRegExp: pattern=%s flags=%s";
10802 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10789 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10803 char* chars = reinterpret_cast<char*>( 10790 char* chars = reinterpret_cast<char*>(
10804 Isolate::Current()->current_zone()->Allocate(len + 1)); 10791 Isolate::Current()->current_zone()->Allocate(len + 1));
10805 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10792 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10806 return chars; 10793 return chars;
10807 } 10794 }
10808 10795
10809 } // namespace dart 10796 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap_test.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698