Commit 3a3d6bd4 authored by aandrey@chromium.org's avatar aandrey@chromium.org

Expose Value::IsArgumentsObject in V8 API.

R=yangguo@chromium.org, svenpanne@chromium.org, yangguo

Review URL: https://codereview.chromium.org/460333002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23105 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a240fd62
......@@ -1423,6 +1423,11 @@ class V8_EXPORT Value : public Data {
*/
bool IsDate() const;
/**
* Returns true if this value is an Arguments object.
*/
bool IsArgumentsObject() const;
/**
* Returns true if this value is a Boolean object.
*/
......
......@@ -2383,6 +2383,14 @@ bool Value::IsNumber() const {
}
bool Value::IsArgumentsObject() const {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
if (!obj->IsHeapObject()) return false;
i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
return obj->HasSpecificClassOf(isolate->heap()->Arguments_string());
}
bool Value::IsBoolean() const {
return Utils::OpenHandle(this)->IsBoolean();
}
......
......@@ -1541,6 +1541,19 @@ THREADED_TEST(IsNativeError) {
}
THREADED_TEST(ArgumentsObject) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
v8::Handle<Value> arguments_object =
CompileRun("var out = 0; (function(){ out = arguments; })(1,2,3); out;");
CHECK(arguments_object->IsArgumentsObject());
v8::Handle<Value> array = CompileRun("[1,2,3]");
CHECK(!array->IsArgumentsObject());
v8::Handle<Value> object = CompileRun("{a:42}");
CHECK(!object->IsArgumentsObject());
}
THREADED_TEST(StringObject) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment