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

Unified Diff: runtime/vm/object.h

Issue 10800002: Hide names of internal classes from the user by mapping them to the documented (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
===================================================================
--- runtime/vm/object.h (revision 9744)
+++ runtime/vm/object.h (working copy)
@@ -352,6 +352,12 @@
kIsMoreSpecificThan
};
+ // Different kinds of name visibility.
+ enum NameVisibility {
+ kInternalName = 0,
+ kUserVisibleName
+ };
+
protected:
// Used for extracting the C++ vtable during bringup.
Object() : raw_(null_) {}
@@ -488,6 +494,8 @@
RawString* Name() const;
+ RawString* UserVisibleName() const;
+
RawScript* script() const { return raw_ptr()->script_; }
intptr_t token_pos() const { return raw_ptr()->token_pos_; }
@@ -775,9 +783,9 @@
Error* malformed_error) const;
HEAP_OBJECT_IMPLEMENTATION(Class, Object);
+ friend class AbstractType;
+ friend class Instance;
friend class Object;
- friend class Instance;
- friend class AbstractType;
friend class Type;
};
@@ -847,8 +855,16 @@
virtual RawAbstractType* Canonicalize() const;
// The name of this type, including the names of its type arguments, if any.
- virtual RawString* Name() const;
+ virtual RawString* Name() const {
+ return BuildName(kInternalName);
+ }
+ // The name of this type, including the names of its type arguments, if any.
+ // Names of internal classes are mapped to their public interfaces.
+ virtual RawString* UserVisibleName() const {
+ return BuildName(kUserVisibleName);
+ }
+
// The name of this type's class, i.e. without the type argument names of this
// type.
RawString* ClassName() const;
@@ -920,10 +936,15 @@
const AbstractType& other,
Error* malformed_error) const;
+ // Return the internal or public name of this type, including the names of its
+ // type arguments, if any.
+ RawString* BuildName(NameVisibility visibility) const;
+
protected:
HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object);
+ friend class AbstractTypeArguments;
friend class Class;
- friend class AbstractTypeArguments;
+ friend class Function;
};
@@ -1050,7 +1071,7 @@
RawClass* parameterized_class() const {
return raw_ptr()->parameterized_class_;
}
- virtual RawString* Name() const { return raw_ptr()->name_; }
+ RawString* name() const { return raw_ptr()->name_; }
intptr_t index() const { return raw_ptr()->index_; }
void set_index(intptr_t value) const;
RawAbstractType* bound() const { return raw_ptr()->bound_; }
@@ -1111,13 +1132,16 @@
// Do not canonicalize InstantiatedTypeArguments or NULL objects
virtual RawAbstractTypeArguments* Canonicalize() const { return this->raw(); }
- // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, int>".
+ // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, Smi>".
virtual RawString* Name() const {
- return SubvectorName(0, Length());
+ return SubvectorName(0, Length(), kInternalName);
}
- // The name of a subvector of this type argument vector, e.g. "<T, Dynamic>".
- virtual RawString* SubvectorName(intptr_t from_index, intptr_t len) const;
+ // The name of this type argument vector, e.g. "<T, Dynamic, List<T>, int>".
+ // Names of internal classes are mapped to their public interfaces.
+ virtual RawString* UserVisibleName() const {
+ return SubvectorName(0, Length(), kUserVisibleName);
+ }
// Check if this type argument vector consists solely of DynamicType,
// considering only a prefix of length 'len'.
@@ -1178,8 +1202,15 @@
intptr_t len,
Error* malformed_error) const;
+ // Return the internal or public name of a subvector of this type argument
+ // vector, e.g. "<T, Dynamic, List<T>, int>".
+ RawString* SubvectorName(intptr_t from_index,
+ intptr_t len,
+ NameVisibility name_visibility) const;
+
protected:
HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object);
+ friend class AbstractType;
friend class Class;
};
@@ -1290,9 +1321,10 @@
RawString* name() const { return raw_ptr()->name_; }
// Build a string of the form '<T, R>(T, [b: B, c: C]) => R' representing the
- // signature of the given function.
+ // internal signature of the given function.
RawString* Signature() const {
- return BuildSignature(false, TypeArguments::Handle());
+ const bool instantiate = false;
+ return BuildSignature(instantiate, kInternalName, TypeArguments::Handle());
}
// Build a string of the form '(A, [b: B, c: C]) => D' representing the
@@ -1300,8 +1332,10 @@
// '<T, R>(T, [b: B, c: C]) => R') are instantiated using the given
// instantiator type argument vector (e.g. '<A, D>').
RawString* InstantiatedSignatureFrom(
- const AbstractTypeArguments& instantiator) const {
- return BuildSignature(true, instantiator);
+ const AbstractTypeArguments& instantiator,
+ NameVisibility name_visibility) const {
+ const bool instantiate = true;
+ return BuildSignature(instantiate, name_visibility, instantiator);
}
// Returns true if the signature of this function is instantiated, i.e. if it
@@ -1582,6 +1616,7 @@
static RawFunction* New();
RawString* BuildSignature(bool instantiate,
+ NameVisibility name_visibility,
const AbstractTypeArguments& instantiator) const;
// Check the subtype or 'more specific' relationship.
@@ -2001,8 +2036,8 @@
HEAP_OBJECT_IMPLEMENTATION(Library, Object);
friend class Class;
+ friend class Debugger;
friend class DictionaryIterator;
- friend class Debugger;
friend class Isolate;
};
@@ -2087,8 +2122,8 @@
static RawInstructions* New(intptr_t size);
HEAP_OBJECT_IMPLEMENTATION(Instructions, Object);
+ friend class Class;
friend class Code;
- friend class Class;
};
@@ -2255,8 +2290,8 @@
void set_bitmap_size_in_bytes(intptr_t value) const;
HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object);
+ friend class BitmapBuilder;
friend class Class;
- friend class BitmapBuilder;
};
@@ -2945,6 +2980,7 @@
virtual int CompareWith(const Integer& other) const;
OBJECT_IMPLEMENTATION(Integer, Number);
+ friend class Class;
};
@@ -3000,8 +3036,6 @@
}
private:
- friend class Api; // For ValueFromRaw
-
static intptr_t ValueFromRaw(uword raw_value) {
intptr_t value = raw_value;
ASSERT((value & kSmiTagMask) == kSmiTag);
@@ -3010,8 +3044,9 @@
static cpp_vtable handle_vtable_;
OBJECT_IMPLEMENTATION(Smi, Integer);
+ friend class Api; // For ValueFromRaw
+ friend class Class;
friend class Object;
- friend class Class;
};
@@ -3125,8 +3160,8 @@
static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew);
HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer);
+ friend class BigintOperations;
friend class Class;
- friend class BigintOperations;
};
@@ -3656,8 +3691,8 @@
static RawBool* New(bool value);
HEAP_OBJECT_IMPLEMENTATION(Bool, Instance);
+ friend class Class;
friend class Object; // To initialize the true and false values.
- friend class Class;
};
@@ -3850,8 +3885,8 @@
static const int kDefaultInitialCapacity = 4;
HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
+ friend class Array;
friend class Class;
- friend class Array;
};
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698