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

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

Issue 1701873003: Let Instance::IsInstanceOf verify that the type we check against is not a (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 14178 matching lines...) Expand 10 before | Expand all | Expand 10 after
14189 ASSERT(field_offset != Class::kNoTypeArguments); 14189 ASSERT(field_offset != Class::kNoTypeArguments);
14190 SetFieldAtOffset(field_offset, value); 14190 SetFieldAtOffset(field_offset, value);
14191 } 14191 }
14192 14192
14193 14193
14194 bool Instance::IsInstanceOf(const AbstractType& other, 14194 bool Instance::IsInstanceOf(const AbstractType& other,
14195 const TypeArguments& other_instantiator, 14195 const TypeArguments& other_instantiator,
14196 Error* bound_error) const { 14196 Error* bound_error) const {
14197 ASSERT(other.IsFinalized()); 14197 ASSERT(other.IsFinalized());
14198 ASSERT(!other.IsDynamicType()); 14198 ASSERT(!other.IsDynamicType());
14199 ASSERT(!other.IsTypeRef()); // Must be dereferenced at compile time.
14199 ASSERT(!other.IsMalformed()); 14200 ASSERT(!other.IsMalformed());
14200 ASSERT(!other.IsMalbounded()); 14201 ASSERT(!other.IsMalbounded());
14201 if (other.IsVoidType()) { 14202 if (other.IsVoidType()) {
14202 return false; 14203 return false;
14203 } 14204 }
14204 Zone* zone = Thread::Current()->zone(); 14205 Zone* zone = Thread::Current()->zone();
14205 const Class& cls = Class::Handle(zone, clazz()); 14206 const Class& cls = Class::Handle(zone, clazz());
14206 if (cls.IsClosureClass()) { 14207 if (cls.IsClosureClass()) {
14207 if (other.IsObjectType() || other.IsDartFunctionType()) { 14208 if (other.IsObjectType() || other.IsDartFunctionType()) {
14208 return true; 14209 return true;
14209 } 14210 }
14210 Function& other_signature = Function::Handle(zone); 14211 Function& other_signature = Function::Handle(zone);
14211 TypeArguments& other_type_arguments = TypeArguments::Handle(zone); 14212 TypeArguments& other_type_arguments = TypeArguments::Handle(zone);
14212 // Note that we may encounter a bound error in checked mode. 14213 // Note that we may encounter a bound error in checked mode.
14213 if (!other.IsInstantiated()) { 14214 if (!other.IsInstantiated()) {
14214 const AbstractType& instantiated_other = AbstractType::Handle( 14215 AbstractType& instantiated_other = AbstractType::Handle(
14215 zone, other.InstantiateFrom(other_instantiator, bound_error, 14216 zone, other.InstantiateFrom(other_instantiator, bound_error,
14216 NULL, NULL, Heap::kOld)); 14217 NULL, NULL, Heap::kOld));
14217 if ((bound_error != NULL) && !bound_error->IsNull()) { 14218 if ((bound_error != NULL) && !bound_error->IsNull()) {
14218 ASSERT(Isolate::Current()->flags().type_checks()); 14219 ASSERT(Isolate::Current()->flags().type_checks());
14219 return false; 14220 return false;
14220 } 14221 }
14222 if (instantiated_other.IsTypeRef()) {
14223 instantiated_other = TypeRef::Cast(instantiated_other).type();
14224 }
14221 if (instantiated_other.IsDynamicType() || 14225 if (instantiated_other.IsDynamicType() ||
14222 instantiated_other.IsObjectType() || 14226 instantiated_other.IsObjectType() ||
14223 instantiated_other.IsDartFunctionType()) { 14227 instantiated_other.IsDartFunctionType()) {
14224 return true; 14228 return true;
14225 } 14229 }
14226 if (!instantiated_other.IsFunctionType()) { 14230 if (!instantiated_other.IsFunctionType()) {
14227 return false; 14231 return false;
14228 } 14232 }
14229 other_signature = FunctionType::Cast(instantiated_other).signature(); 14233 other_signature = FunctionType::Cast(instantiated_other).signature();
14230 other_type_arguments = instantiated_other.arguments(); 14234 other_type_arguments = instantiated_other.arguments();
(...skipping 7197 matching lines...) Expand 10 before | Expand all | Expand 10 after
21428 return UserTag::null(); 21432 return UserTag::null();
21429 } 21433 }
21430 21434
21431 21435
21432 const char* UserTag::ToCString() const { 21436 const char* UserTag::ToCString() const {
21433 const String& tag_label = String::Handle(label()); 21437 const String& tag_label = String::Handle(label());
21434 return tag_label.ToCString(); 21438 return tag_label.ToCString();
21435 } 21439 }
21436 21440
21437 } // namespace dart 21441 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698