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

Unified Diff: runtime/vm/object.h

Issue 2979763002: [VM generic function types] Properly set the scope function after parsing a (Closed)
Patch Set: work in progress Created 3 years, 5 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
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index e7316e74a049d32c0e6685c58185edadb25173f9..38e43ab70ec13af3c4ef7736c0cab780c3742e80 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1679,6 +1679,9 @@ class TypeArguments : public Object {
// Return true if this vector contains a recursive type argument.
bool IsRecursive() const;
+ // Set the scope of this type argument vector to the given function.
+ void SetScopeFunction(const Function& function) const;
+
// Clone this type argument vector and clone all unfinalized type arguments.
// Finalized type arguments are shared.
RawTypeArguments* CloneUnfinalized() const;
@@ -2221,9 +2224,6 @@ class Function : public Object {
RawType* SignatureType() const;
RawType* ExistingSignatureType() const;
- // Allocate and return a signature function equivalent to this function.
- RawFunction* CanonicalSignatureFunction(TrailPtr trail) const;
-
// Update the signature type (with a canonical version).
void SetSignatureType(const Type& value) const;
@@ -2233,14 +2233,16 @@ class Function : public Object {
const TypeArguments& function_type_arguments,
Heap::Space space) const;
- // Build a string of the form '(T, {B b, C c}) => R' representing the
- // internal signature of the given function. In this example, T and R are
- // type parameters of class C, the owner of the function.
+ // Build a string of the form '<T>(T, {B b, C c}) => R' representing the
+ // internal signature of the given function. In this example, T is a type
+ // parameter of this function and R is a type parameter of class C, the owner
+ // of the function. B and C are not type parameters.
RawString* Signature() const { return BuildSignature(kInternalName); }
- // Build a string of the form '(T, {B b, C c}) => R' representing the
- // user visible signature of the given function. In this example, T and R are
- // type parameters of class C, the owner of the function.
+ // Build a string of the form '<T>(T, {B b, C c}) => R' representing the
+ // user visible signature of the given function. In this example, T is a type
+ // parameter of this function and R is a type parameter of class C, the owner
+ // of the function. B and C are not type parameters.
// Implicit parameters are hidden.
RawString* UserVisibleSignature() const {
return BuildSignature(kUserVisibleName);
@@ -2248,6 +2250,9 @@ class Function : public Object {
// Returns true if the signature of this function is instantiated, i.e. if it
// does not involve generic parameter types or generic result type.
+ // Note that function type parameters declared by this function do not make
+ // its signature uninstantiated, only type parameters declared by parent
+ // generic functions or class type parameters.
bool HasInstantiatedSignature(Genericity genericity = kAny,
intptr_t num_free_fun_type_params = kMaxInt32,
TrailPtr trail = NULL) const;
@@ -2308,6 +2313,9 @@ class Function : public Object {
// Return the number of type parameters declared in parent generic functions.
intptr_t NumParentTypeParameters() const;
+ // Print the signature type of this function and of all of its parents.
+ void PrintSignatureTypes() const;
+
// Return a TypeParameter if the type_name is a type parameter of this
// function or of one of its parent functions.
// Unless NULL, adjust function_level accordingly (in and out parameter).
@@ -3060,6 +3068,7 @@ class Function : public Object {
// Function.
friend class RawFunction;
friend class ClassFinalizer; // To reset parent_function.
+ friend class Type; // To adjust parent_function.
};
@@ -5739,6 +5748,9 @@ class AbstractType : public Instance {
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const;
+ // Set the scope of this type to the given function.
+ virtual void SetScopeFunction(const Function& function) const;
+
// Check if this type represents a function type.
virtual bool IsFunctionType() const { return false; }
@@ -5954,6 +5966,7 @@ class Type : public AbstractType {
TrailPtr trail = NULL) const;
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const;
+ virtual void SetScopeFunction(const Function& function) const;
// If signature is not null, this type represents a function type. Note that
// the signature fully represents the type and type arguments can be ignored.
// However, in case of a generic typedef, they document how the typedef class
@@ -6104,6 +6117,7 @@ class TypeRef : public AbstractType {
TrailPtr trail = NULL) const;
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const { return true; }
+ virtual void SetScopeFunction(const Function& function) const;
virtual RawTypeRef* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
const TypeArguments& function_type_arguments,
@@ -6190,6 +6204,7 @@ class TypeParameter : public AbstractType {
TrailPtr trail = NULL) const;
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const { return false; }
+ virtual void SetScopeFunction(const Function& function) const {}
virtual RawAbstractType* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
const TypeArguments& function_type_arguments,
@@ -6292,6 +6307,7 @@ class BoundedType : public AbstractType {
}
virtual bool IsEquivalent(const Instance& other, TrailPtr trail = NULL) const;
virtual bool IsRecursive() const;
+ virtual void SetScopeFunction(const Function& function) const;
virtual RawAbstractType* InstantiateFrom(
const TypeArguments& instantiator_type_arguments,
const TypeArguments& function_type_arguments,

Powered by Google App Engine
This is Rietveld 408576698