diff --git a/ecmascript/js_hclass.h b/ecmascript/js_hclass.h index e12d76cbfb84f47e3788c56b7c3ebe5982fc581d..f5ea36c10247f1c4bd0c66943b40df2a29c671da 100644 --- a/ecmascript/js_hclass.h +++ b/ecmascript/js_hclass.h @@ -312,6 +312,11 @@ public: return GetObjectType() == JSType::STRING; } + inline bool IsSymbol() const + { + return GetObjectType() == JSType::SYMBOL; + } + inline bool IsStringOrSymbol() const { JSType jsType = GetObjectType(); diff --git a/ecmascript/napi/include/jsnapi.h b/ecmascript/napi/include/jsnapi.h index a3a4885cf4636242e3d6750773582c454e5cf167..c75aba703ef71515ad0d374f3cac4c200cd45a83 100644 --- a/ecmascript/napi/include/jsnapi.h +++ b/ecmascript/napi/include/jsnapi.h @@ -315,6 +315,13 @@ public: bool IsJSPrimitiveBoolean(); bool IsJSPrimitiveString(); + bool IsGeneratorObject(); + bool IsJSPrimitiveSymbol(); + + bool IsArgumentsObject(); + bool IsGeneratorFunction(); + bool IsAsyncFunction(); + bool IsStrictEquals(const EcmaVM *vm, Local value); Local Typeof(const EcmaVM *vm); bool InstanceOf(const EcmaVM *vm, Local value); diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index edad0b42654c23113b71a0bdd9b4149176eec08f..8c4b90c0b0cfd3d1d7e1dbd4a22bcfbf8fd3acf2 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -1813,4 +1813,38 @@ bool JSValueRef::IsJSPrimitiveString() JSHandle obj = JSNApiHelper::ToJSHandle(this); return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsString(); } + +bool JSValueRef::IsJSPrimitiveSymbol() +{ + JSHandle obj = JSNApiHelper::ToJSHandle(this); + return JSPrimitiveRef::Cast(obj->GetHeapObject())->IsSymbol(); +} + +bool JSValueRef::IsGeneratorObject() +{ + JSHandle obj = JSNApiHelper::ToJSHandle(this); + bool rst = obj->IsGeneratorObject(); + return rst; +} + +bool JSValueRef::IsAsyncFunction() +{ + JSHandle obj = JSNApiHelper::ToJSHandle(this); + bool rst = obj->IsJSAsyncFunction(); + return rst; +} + +bool JSValueRef::IsArgumentsObject() +{ + JSHandle obj = JSNApiHelper::ToJSHandle(this); + bool rst = obj->IsArguments(); + return rst; +} + +bool JSValueRef::IsGeneratorFunction() +{ + JSHandle obj = JSNApiHelper::ToJSHandle(this); + bool rst = obj->IsGeneratorFunction(); + return rst; +} } // namespace panda