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

Unified Diff: runtime/vm/object.h

Issue 211963003: Detect and reject illegal recursive types (non-contractive types). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 34402)
+++ runtime/vm/object.h (working copy)
@@ -1300,24 +1300,39 @@
return TypeTest(kIsMoreSpecificThan, other, from_index, len, bound_error);
}
- // Check if the vectors are equal.
+ // Check if the vectors are equal (they may be null).
bool Equals(const TypeArguments& other) const {
- return IsEquivalent(other);
+ return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length());
}
bool IsEquivalent(const TypeArguments& other,
- GrowableObjectArray* trail = NULL) const;
+ GrowableObjectArray* trail = NULL) const {
+ return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(), trail);
+ }
+ bool IsSubvectorEquivalent(const TypeArguments& other,
+ intptr_t from_index,
+ intptr_t len,
+ GrowableObjectArray* trail = NULL) const;
- bool IsInstantiated(GrowableObjectArray* trail = NULL) const;
+ // Check if the vector is instantiated (it must not be null).
+ bool IsInstantiated(GrowableObjectArray* trail = NULL) const {
+ return IsSubvectorInstantiated(0, Length(), trail);
+ }
+ bool IsSubvectorInstantiated(intptr_t from_index,
+ intptr_t len,
+ GrowableObjectArray* trail = NULL) const;
bool IsUninstantiatedIdentity() const;
bool CanShareInstantiatorTypeArguments(const Class& instantiator_class) const;
- // Returns true if all types of this vector are respectively, resolved,
+ // Return true if all types of this vector are respectively, resolved,
// finalized, or bounded.
bool IsResolved() const;
bool IsFinalized() const;
bool IsBounded() const;
+ // Return true if this vector contains a recursive type argument.
+ bool IsRecursive() const;
+
// Clone this type argument vector and clone all unfinalized type arguments.
// Finalized type arguments are shared.
RawTypeArguments* CloneUnfinalized() const;
@@ -4129,6 +4144,7 @@
}
virtual bool IsEquivalent(const Instance& other,
GrowableObjectArray* trail = NULL) const;
+ virtual bool IsRecursive() const;
// Instantiate this type using the given type argument vector.
// Return a new type, or return 'this' if it is already instantiated.
@@ -4151,6 +4167,15 @@
virtual RawAbstractType* Canonicalize(
GrowableObjectArray* trail = NULL) const;
+ // Return the object associated with the receiver in the trail or
+ // Object::null() if the receiver is not contained in the trail.
+ RawObject* OnlyBuddyInTrail(GrowableObjectArray* trail) const;
+
+ // If the trail is null, allocate a trail, add the pair <receiver, buddy> to
+ // the trail. The receiver may only be added once with its only buddy.
+ void AddOnlyBuddyToTrail(GrowableObjectArray** trail,
+ const Object& buddy) const;
+
// The name of this type, including the names of its type arguments, if any.
virtual RawString* Name() const {
return BuildName(kInternalName);
@@ -4284,6 +4309,7 @@
virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const;
virtual bool IsEquivalent(const Instance& other,
GrowableObjectArray* trail = NULL) const;
+ virtual bool IsRecursive() const;
virtual RawAbstractType* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* malformed_error,
@@ -4402,6 +4428,7 @@
virtual bool IsInstantiated(GrowableObjectArray* trail = NULL) const;
virtual bool IsEquivalent(const Instance& other,
GrowableObjectArray* trail = NULL) const;
+ virtual bool IsRecursive() const { return true; }
virtual RawAbstractType* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
@@ -4423,15 +4450,6 @@
bool TestAndAddBuddyToTrail(GrowableObjectArray** trail,
const Object& buddy) const;
- // Return the object associated with the receiver in the trail or
- // Object::null() if the receiver is not contained in the trail.
- RawObject* OnlyBuddyInTrail(GrowableObjectArray* trail) const;
-
- // If the trail is null, allocate a trail, add the pair <receiver, buddy> to
- // the trail. The receiver may only be added once with its only buddy.
- void AddOnlyBuddyToTrail(GrowableObjectArray** trail,
- const Object& buddy) const;
-
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(RawTypeRef));
}
@@ -4490,6 +4508,7 @@
}
virtual bool IsEquivalent(const Instance& other,
GrowableObjectArray* trail = NULL) const;
+ virtual bool IsRecursive() const { return false; }
virtual RawAbstractType* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,
@@ -4573,6 +4592,7 @@
}
virtual bool IsEquivalent(const Instance& other,
GrowableObjectArray* trail = NULL) const;
+ virtual bool IsRecursive() const;
virtual RawAbstractType* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
Error* bound_error,

Powered by Google App Engine
This is Rietveld 408576698