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

Unified Diff: src/objects.h

Issue 9600013: Use an enum for indicating the component of an AccessorPair instead of a boolean flag. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporated review comments. Created 8 years, 10 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 | « no previous file | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 482b7944644361cd50f0728cc064b5a6dcd0e5fa..2b8888b9ef324fb84d143ab9eef2e6cde59c0cdb 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -1360,6 +1360,13 @@ enum SetPropertyMode {
};
+// Indicator for one component of an AccessorPair.
+enum AccessorComponent {
+ ACCESSOR_GETTER,
+ ACCESSOR_SETTER
+};
+
+
// JSReceiver includes types on which properties can be defined, i.e.,
// JSObject and JSProxy.
class JSReceiver: public HeapObject {
@@ -1612,10 +1619,10 @@ class JSObject: public JSReceiver {
bool continue_search);
MUST_USE_RESULT MaybeObject* DefineAccessor(String* name,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes);
- Object* LookupAccessor(String* name, bool is_getter);
+ Object* LookupAccessor(String* name, AccessorComponent component);
MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info);
@@ -2166,12 +2173,12 @@ class JSObject: public JSReceiver {
PropertyAttributes attributes);
MUST_USE_RESULT MaybeObject* DefineElementAccessor(
uint32_t index,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes);
MUST_USE_RESULT MaybeObject* DefinePropertyAccessor(
String* name,
- bool is_getter,
+ AccessorComponent component,
Object* fun,
PropertyAttributes attributes);
void LookupInDescriptor(String* name, LookupResult* result);
@@ -7927,9 +7934,14 @@ class AccessorPair: public Struct {
MUST_USE_RESULT MaybeObject* CopyWithoutTransitions();
- // TODO(svenpanne) Evil temporary helper, will vanish soon...
- void set(bool modify_getter, Object* value) {
- if (modify_getter) {
+ Object* get(AccessorComponent component) {
+ ASSERT(component == ACCESSOR_GETTER || component == ACCESSOR_SETTER);
+ return (component == ACCESSOR_GETTER) ? getter() : setter();
+ }
+
+ void set(AccessorComponent component, Object* value) {
+ ASSERT(component == ACCESSOR_GETTER || component == ACCESSOR_SETTER);
+ if (component == ACCESSOR_GETTER) {
set_getter(value);
} else {
set_setter(value);
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698