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

Unified Diff: runtime/vm/object.h

Issue 2761933002: Add Genericity enum in VM to distinguish how a type is uninstantiated. (Closed)
Patch Set: sync Created 3 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
« no previous file with comments | « runtime/vm/kernel_to_il.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index d208ee2e524689f45d174042ce5af94e68c7db5d..a413cd8de7990042ecf128d8545361c41563b108 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1548,6 +1548,16 @@ class UnresolvedClass : public Object {
};
+// Classification of type genericity according to type parameter owners.
+enum Genericity {
+ kAny, // Consider type params of class and functions.
+ kClass, // Consider type params of class only.
+ kFunctions, // Consider type params of current and parent functions.
+ kCurrentFunction, // Consider type params of current function only.
+ kParentFunctions // Consider type params of parent functions only.
+};
+
+
// A TypeArguments is an array of AbstractType.
class TypeArguments : public Object {
public:
@@ -1625,11 +1635,13 @@ class TypeArguments : public Object {
TrailPtr trail = NULL) const;
// Check if the vector is instantiated (it must not be null).
- bool IsInstantiated(TrailPtr trail = NULL) const {
- return IsSubvectorInstantiated(0, Length(), trail);
+ bool IsInstantiated(Genericity genericity = kAny,
+ TrailPtr trail = NULL) const {
+ return IsSubvectorInstantiated(0, Length(), genericity, trail);
}
bool IsSubvectorInstantiated(intptr_t from_index,
intptr_t len,
+ Genericity genericity = kAny,
TrailPtr trail = NULL) const;
bool IsUninstantiatedIdentity() const;
bool CanShareInstantiatorTypeArguments(const Class& instantiator_class) const;
@@ -2275,6 +2287,9 @@ class Function : public Object {
// Return true if this function declares type parameters.
bool IsGeneric() const { return NumTypeParameters(Thread::Current()) > 0; }
+ // Return true if any parent function of this function is generic.
+ bool HasGenericParent() const;
+
// Not thread-safe; must be called in the main thread.
// Sets function's code and code's function.
void InstallOptimizedCode(const Code& code, bool is_osr) const;
@@ -5678,7 +5693,8 @@ class AbstractType : public Instance {
virtual RawTypeArguments* arguments() const;
virtual void set_arguments(const TypeArguments& value) const;
virtual TokenPosition token_pos() const;
- virtual bool IsInstantiated(TrailPtr trail = NULL) const;
+ virtual bool IsInstantiated(Genericity genericity = kAny,
+ TrailPtr trail = NULL) const;
virtual bool CanonicalizeEquals(const Instance& other) const {
return Equals(other);
}
@@ -5893,7 +5909,8 @@ class Type : public AbstractType {
virtual RawTypeArguments* arguments() const { return raw_ptr()->arguments_; }
virtual void set_arguments(const TypeArguments& value) const;
virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
- virtual bool IsInstantiated(TrailPtr trail = NULL) const;
+ virtual bool IsInstantiated(Genericity genericity = kAny,
+ TrailPtr trail = NULL) const;
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const;
// If signature is not null, this type represents a function type.
@@ -6031,7 +6048,8 @@ class TypeRef : public AbstractType {
virtual TokenPosition token_pos() const {
return AbstractType::Handle(type()).token_pos();
}
- virtual bool IsInstantiated(TrailPtr trail = NULL) const;
+ virtual bool IsInstantiated(Genericity genericity = kAny,
+ TrailPtr trail = NULL) const;
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const { return true; }
virtual RawTypeRef* InstantiateFrom(
@@ -6115,7 +6133,8 @@ class TypeParameter : public AbstractType {
TrailPtr bound_trail,
Heap::Space space) const;
virtual TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
- virtual bool IsInstantiated(TrailPtr trail = NULL) const { return false; }
+ virtual bool IsInstantiated(Genericity genericity = kAny,
+ TrailPtr trail = NULL) const;
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const { return false; }
virtual RawAbstractType* InstantiateFrom(
@@ -6209,12 +6228,13 @@ class BoundedType : public AbstractType {
virtual TokenPosition token_pos() const {
return AbstractType::Handle(type()).token_pos();
}
- virtual bool IsInstantiated(TrailPtr trail = NULL) const {
+ virtual bool IsInstantiated(Genericity genericity = kAny,
+ TrailPtr trail = NULL) const {
// It is not possible to encounter an instantiated bounded type with an
// uninstantiated upper bound. Therefore, we do not need to check if the
// bound is instantiated. Moreover, doing so could lead into cycles, as in
// class C<T extends C<C>> { }.
- return AbstractType::Handle(type()).IsInstantiated(trail);
+ return AbstractType::Handle(type()).IsInstantiated(genericity, trail);
}
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const;
« no previous file with comments | « runtime/vm/kernel_to_il.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698