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

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

Issue 33313003: Report use of malbounded interface in type test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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/exceptions.cc ('k') | tests/language/language.status » ('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 "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 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 return true; 2781 return true;
2782 } 2782 }
2783 } 2783 }
2784 } 2784 }
2785 // Check for 'direct super type' specified in the implements clause 2785 // Check for 'direct super type' specified in the implements clause
2786 // and check for transitivity at the same time. 2786 // and check for transitivity at the same time.
2787 Array& interfaces = Array::Handle(this->interfaces()); 2787 Array& interfaces = Array::Handle(this->interfaces());
2788 AbstractType& interface = AbstractType::Handle(); 2788 AbstractType& interface = AbstractType::Handle();
2789 Class& interface_class = Class::Handle(); 2789 Class& interface_class = Class::Handle();
2790 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle(); 2790 AbstractTypeArguments& interface_args = AbstractTypeArguments::Handle();
2791 Error& args_bound_error = Error::Handle(); 2791 Error& error = Error::Handle();
2792 for (intptr_t i = 0; i < interfaces.Length(); i++) { 2792 for (intptr_t i = 0; i < interfaces.Length(); i++) {
2793 interface ^= interfaces.At(i); 2793 interface ^= interfaces.At(i);
2794 if (!interface.IsFinalized()) { 2794 if (!interface.IsFinalized()) {
2795 // We may be checking bounds at finalization time. Skipping this 2795 // We may be checking bounds at finalization time. Skipping this
2796 // unfinalized interface will postpone bound checking to run time. 2796 // unfinalized interface will postpone bound checking to run time.
2797 continue; 2797 continue;
2798 } 2798 }
2799 error = Error::null();
2800 if (interface.IsMalboundedWithError(&error)) {
2801 // Return the first bound error to the caller if it requests it.
2802 if ((bound_error != NULL) && bound_error->IsNull()) {
2803 ASSERT(!error.IsNull());
2804 *bound_error = error.raw();
2805 }
2806 continue; // Another interface may work better.
2807 }
2799 interface_class = interface.type_class(); 2808 interface_class = interface.type_class();
2800 interface_args = interface.arguments(); 2809 interface_args = interface.arguments();
2801 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) { 2810 if (!interface_args.IsNull() && !interface_args.IsInstantiated()) {
2802 // This type class implements an interface that is parameterized with 2811 // This type class implements an interface that is parameterized with
2803 // generic type(s), e.g. it implements List<T>. 2812 // generic type(s), e.g. it implements List<T>.
2804 // The uninstantiated type T must be instantiated using the type 2813 // The uninstantiated type T must be instantiated using the type
2805 // parameters of this type before performing the type test. 2814 // parameters of this type before performing the type test.
2806 // The type arguments of this type that are referred to by the type 2815 // The type arguments of this type that are referred to by the type
2807 // parameters of the interface are at the end of the type vector, 2816 // parameters of the interface are at the end of the type vector,
2808 // after the type arguments of the super type of this type. 2817 // after the type arguments of the super type of this type.
2809 // The index of the type parameters is adjusted upon finalization. 2818 // The index of the type parameters is adjusted upon finalization.
2810 args_bound_error = Error::null(); 2819 error = Error::null();
2811 interface_args = interface_args.InstantiateFrom(type_arguments, 2820 interface_args = interface_args.InstantiateFrom(type_arguments, &error);
2812 &args_bound_error); 2821 if (!error.IsNull()) {
2813 if (!args_bound_error.IsNull()) {
2814 // Return the first bound error to the caller if it requests it. 2822 // Return the first bound error to the caller if it requests it.
2815 if ((bound_error != NULL) && bound_error->IsNull()) { 2823 if ((bound_error != NULL) && bound_error->IsNull()) {
2816 *bound_error = args_bound_error.raw(); 2824 *bound_error = error.raw();
2817 } 2825 }
2818 continue; // Another interface may work better. 2826 continue; // Another interface may work better.
2819 } 2827 }
2820 } 2828 }
2821 if (interface_class.TypeTest(test_kind, 2829 if (interface_class.TypeTest(test_kind,
2822 interface_args, 2830 interface_args,
2823 other, 2831 other,
2824 other_type_arguments, 2832 other_type_arguments,
2825 bound_error)) { 2833 bound_error)) {
2826 return true; 2834 return true;
(...skipping 12732 matching lines...) Expand 10 before | Expand all | Expand 10 after
15559 return "_MirrorReference"; 15567 return "_MirrorReference";
15560 } 15568 }
15561 15569
15562 15570
15563 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15571 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15564 JSONObject jsobj(stream); 15572 JSONObject jsobj(stream);
15565 } 15573 }
15566 15574
15567 15575
15568 } // namespace dart 15576 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698