From 58dd7b5a1308919ef8b4b28e36c6223b5fc0ebde Mon Sep 17 00:00:00 2001 From: Jack Horton Date: Tue, 6 Mar 2018 17:00:24 -0800 Subject: [PATCH] chakrashim: add newly-used V8 functions --- deps/chakrashim/include/v8.h | 2 + deps/chakrashim/lib/chakra_shim.js | 11 +++- .../src/jsrtcachedpropertyidref.inc | 2 + deps/chakrashim/src/v8value.cc | 51 +++++++------------ 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/deps/chakrashim/include/v8.h b/deps/chakrashim/include/v8.h index 2c83cad106f..057cd22b589 100644 --- a/deps/chakrashim/include/v8.h +++ b/deps/chakrashim/include/v8.h @@ -1101,6 +1101,8 @@ class V8_EXPORT Value : public Data { bool IsRegExp() const; bool IsAsyncFunction() const; bool IsGeneratorObject() const; + bool IsGeneratorFunction() const; + bool IsWebAssemblyCompiledModule() const; bool IsExternal() const; bool IsArrayBuffer() const; bool IsArrayBufferView() const; diff --git a/deps/chakrashim/lib/chakra_shim.js b/deps/chakrashim/lib/chakra_shim.js index d636cbaed6b..b8531358dcc 100644 --- a/deps/chakrashim/lib/chakra_shim.js +++ b/deps/chakrashim/lib/chakra_shim.js @@ -580,8 +580,7 @@ }; utils.isAsyncFunction = function(obj) { - // CHAKRA-TODO - return false; + return compareType(obj, 'AsyncFunction'); }; utils.isSet = function(obj) { @@ -604,6 +603,14 @@ return compareType(obj, 'Generator'); }; + utils.isGeneratorFunction = function(obj) { + return compareType(obj, 'GeneratorFunction'); + }; + + utils.isWebAssemblyCompiledModule = function(obj) { + return compareType(obj, 'WebAssembly.Module'); + }; + utils.isWeakMap = function(obj) { return compareType(obj, 'WeakMap'); }; diff --git a/deps/chakrashim/src/jsrtcachedpropertyidref.inc b/deps/chakrashim/src/jsrtcachedpropertyidref.inc index 40242b4c3d9..d50b369f42b 100644 --- a/deps/chakrashim/src/jsrtcachedpropertyidref.inc +++ b/deps/chakrashim/src/jsrtcachedpropertyidref.inc @@ -155,6 +155,8 @@ DEF_IS_TYPE(isStringObject) DEF_IS_TYPE(isNumberObject) DEF_IS_TYPE(isArgumentsObject) DEF_IS_TYPE(isGeneratorObject) +DEF_IS_TYPE(isGeneratorFunction) +DEF_IS_TYPE(isWebAssemblyCompiledModule) DEF_IS_TYPE(isWeakMap) DEF_IS_TYPE(isWeakSet) DEF_IS_TYPE(isSymbolObject) diff --git a/deps/chakrashim/src/v8value.cc b/deps/chakrashim/src/v8value.cc index 8936e9a7c9e..6232bdfdf08 100644 --- a/deps/chakrashim/src/v8value.cc +++ b/deps/chakrashim/src/v8value.cc @@ -64,21 +64,20 @@ bool Value::IsFalse() const { return this == jsrt::GetFalse(); } -bool Value::IsString() const { - return IsOfType(this, JsValueType::JsString); +#define ISJSVALUETYPE(Type) \ +bool Value::Is##Type() const { \ + return IsOfType(this, JsValueType::Js##Type); \ } -bool Value::IsSymbol() const { - return IsOfType(this, JsValueType::JsSymbol); -} - -bool Value::IsFunction() const { - return IsOfType(this, JsValueType::JsFunction); -} - -bool Value::IsArray() const { - return IsOfType(this, JsValueType::JsArray); -} +ISJSVALUETYPE(String) +ISJSVALUETYPE(Symbol) +ISJSVALUETYPE(Function) +ISJSVALUETYPE(Array) +ISJSVALUETYPE(ArrayBuffer) +ISJSVALUETYPE(TypedArray) +ISJSVALUETYPE(DataView) +ISJSVALUETYPE(Boolean) +ISJSVALUETYPE(Number) bool Value::IsObject() const { JsValueType type; @@ -93,14 +92,6 @@ bool Value::IsExternal() const { return External::IsExternal(this); } -bool Value::IsArrayBuffer() const { - return IsOfType(this, JsValueType::JsArrayBuffer); -} - -bool Value::IsTypedArray() const { - return IsOfType(this, JsValueType::JsTypedArray); -} - #define DEFINE_TYPEDARRAY_CHECK(ArrayType) \ bool Value::Is##ArrayType##Array() const { \ JsTypedArrayType typedArrayType; \ @@ -125,18 +116,6 @@ bool Value::IsArrayBufferView() const { return IsTypedArray() || IsDataView(); } -bool Value::IsDataView() const { - return IsOfType(this, JsValueType::JsDataView); -} - -bool Value::IsBoolean() const { - return IsOfType(this, JsValueType::JsBoolean); -} - -bool Value::IsNumber() const { - return IsOfType(this, JsValueType::JsNumber); -} - bool Value::IsInt32() const { if (!IsNumber()) { return false; @@ -175,8 +154,10 @@ if (errorCode != JsNoError) { \ return false; \ } \ return Local(resultRef)->BooleanValue(); \ -} \ +} +// Refer to jsrtcachedpropertyidref.inc for the full list +// DEF_IS_TYPE is not structured correctly in order to be used here IS_TYPE_FUNCTION(IsBooleanObject, isBooleanObject) IS_TYPE_FUNCTION(IsDate, isDate) IS_TYPE_FUNCTION(IsMap, isMap) @@ -192,6 +173,8 @@ IS_TYPE_FUNCTION(IsMapIterator, isMapIterator) IS_TYPE_FUNCTION(IsSetIterator, isSetIterator) IS_TYPE_FUNCTION(IsArgumentsObject, isArgumentsObject) IS_TYPE_FUNCTION(IsGeneratorObject, isGeneratorObject) +IS_TYPE_FUNCTION(IsGeneratorFunction, isGeneratorFunction) +IS_TYPE_FUNCTION(IsWebAssemblyCompiledModule, isWebAssemblyCompiledModule) IS_TYPE_FUNCTION(IsWeakMap, isWeakMap) IS_TYPE_FUNCTION(IsWeakSet, isWeakSet) IS_TYPE_FUNCTION(IsSymbolObject, isSymbolObject)