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

Unified Diff: src/objects.cc

Issue 7321006: Add GetPropertyAttribute method for Object in the API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add proper exception handling Created 9 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: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 1157d723701648c2ee2d05c908c4b338722bbeaa..9843caad8dcb4ce8fd275ff9dac3785bafb36b95 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2601,6 +2601,36 @@ PropertyAttributes JSReceiver::GetPropertyAttribute(JSReceiver* receiver,
}
+PropertyAttributes JSReceiver::TryGetPropertyAttribute(
+ Handle<Object> key,
+ bool* has_pending_exception) {
+ Isolate* isolate = GetHeap()->isolate();
+ HandleScope scope(isolate);
+
+ Handle<String> name;
+ if (key->IsString()) {
+ name = Handle<String>::cast(key);
+ } else {
+ bool has_pending_exception = false;
+ Handle<Object> converted =
+ Execution::ToString(key, &has_pending_exception);
+ if (has_pending_exception) return ABSENT;
+ name = Handle<String>::cast(converted);
+ }
+ PropertyAttributes attr = GetPropertyAttributeWithReceiver(this, *name);
+
+ // Throws an exception when the property doesn't exist.
Mads Ager (chromium) 2011/07/15 07:25:51 Let's just return NONE in that case and document t
+ if (attr == ABSENT) {
+ i::Handle<i::Object> error_obj = isolate->factory()->NewReferenceError(
+ "not_defined", i::HandleVector(&name, 1));
+ isolate->Throw(*error_obj);
+ *has_pending_exception = true;
+ }
+
+ return attr;
+}
+
+
PropertyAttributes JSReceiver::GetLocalPropertyAttribute(String* name) {
// Check whether the name is an array index.
uint32_t index = 0;

Powered by Google App Engine
This is Rietveld 408576698