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

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

Issue 8592004: null is an instance of Dynamic (fix issue 443). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 5020 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 5031
5032 5032
5033 bool Instance::TestType(TypeTestKind test, 5033 bool Instance::TestType(TypeTestKind test,
5034 const Type& other, 5034 const Type& other,
5035 const TypeArguments& other_instantiator) const { 5035 const TypeArguments& other_instantiator) const {
5036 ASSERT(other.IsFinalized()); 5036 ASSERT(other.IsFinalized());
5037 ASSERT(!other.IsDynamicType()); 5037 ASSERT(!other.IsDynamicType());
5038 ASSERT(!other.IsVoidType()); 5038 ASSERT(!other.IsVoidType());
5039 if (IsNull()) { 5039 if (IsNull()) {
5040 if (test == Type::kIsSubtypeOf) { 5040 if (test == Type::kIsSubtypeOf) {
5041 const Type& object_type = 5041 Class& other_class = Class::Handle();
5042 Type::Handle(Isolate::Current()->object_store()->object_type()); 5042 if (other.IsTypeParameter()) {
5043 if (other.IsInstantiated() && object_type.IsSubtypeOf(other)) { 5043 if (other_instantiator.IsNull()) {
5044 ASSERT(other_instantiator.IsNull()); 5044 return true; // Other type is uninstantiated, i.e. Dynamic.
5045 // null is an instance of the Object class. 5045 }
5046 return true; 5046 const Type& instantiated_other =
5047 Type::Handle(other_instantiator.TypeAt(other.Index()));
5048 ASSERT(instantiated_other.IsInstantiated());
5049 other_class = instantiated_other.type_class();
5050 } else {
5051 other_class = other.type_class();
5047 } 5052 }
5048 return false; 5053 return other_class.IsObjectClass() || other_class.IsDynamicClass();
5049 } else { 5054 } else {
5050 ASSERT(test == Type::kIsAssignableTo); 5055 ASSERT(test == Type::kIsAssignableTo);
5051 return true; 5056 return true;
5052 } 5057 }
5053 } 5058 }
5054 const Class& cls = Class::Handle(clazz()); 5059 const Class& cls = Class::Handle(clazz());
5055 TypeArguments& type_arguments = TypeArguments::Handle(); 5060 TypeArguments& type_arguments = TypeArguments::Handle();
5056 const intptr_t num_type_arguments = cls.NumTypeArguments(); 5061 const intptr_t num_type_arguments = cls.NumTypeArguments();
5057 if (num_type_arguments > 0) { 5062 if (num_type_arguments > 0) {
5058 type_arguments = GetTypeArguments(); 5063 type_arguments = GetTypeArguments();
(...skipping 2208 matching lines...) Expand 10 before | Expand all | Expand 10 after
7267 const String& str = String::Handle(pattern()); 7272 const String& str = String::Handle(pattern());
7268 const char* format = "JSRegExp: pattern=%s flags=%s"; 7273 const char* format = "JSRegExp: pattern=%s flags=%s";
7269 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7274 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7270 char* chars = reinterpret_cast<char*>( 7275 char* chars = reinterpret_cast<char*>(
7271 Isolate::Current()->current_zone()->Allocate(len + 1)); 7276 Isolate::Current()->current_zone()->Allocate(len + 1));
7272 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7277 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7273 return chars; 7278 return chars;
7274 } 7279 }
7275 7280
7276 } // namespace dart 7281 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698