Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit df18390

Browse files
committed
chakrashim: add newly-used V8 functions
1 parent 11954ba commit df18390

File tree

4 files changed

+30
-36
lines changed

4 files changed

+30
-36
lines changed

deps/chakrashim/include/v8.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,8 @@ class V8_EXPORT Value : public Data {
11011101
bool IsRegExp() const;
11021102
bool IsAsyncFunction() const;
11031103
bool IsGeneratorObject() const;
1104+
bool IsGeneratorFunction() const;
1105+
bool IsWebAssemblyCompiledModule() const;
11041106
bool IsExternal() const;
11051107
bool IsArrayBuffer() const;
11061108
bool IsArrayBufferView() const;

deps/chakrashim/lib/chakra_shim.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,7 @@
580580
};
581581

582582
utils.isAsyncFunction = function(obj) {
583-
// CHAKRA-TODO
584-
return false;
583+
return compareType(obj, 'AsyncFunction');
585584
};
586585

587586
utils.isSet = function(obj) {
@@ -604,6 +603,14 @@
604603
return compareType(obj, 'Generator');
605604
};
606605

606+
utils.isGeneratorFunction = function(obj) {
607+
return compareType(obj, 'GeneratorFunction');
608+
};
609+
610+
utils.isWebAssemblyCompiledModule = function(obj) {
611+
return compareType(obj, 'WebAssembly.Module');
612+
};
613+
607614
utils.isWeakMap = function(obj) {
608615
return compareType(obj, 'WeakMap');
609616
};

deps/chakrashim/src/jsrtcachedpropertyidref.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ DEF_IS_TYPE(isStringObject)
155155
DEF_IS_TYPE(isNumberObject)
156156
DEF_IS_TYPE(isArgumentsObject)
157157
DEF_IS_TYPE(isGeneratorObject)
158+
DEF_IS_TYPE(isGeneratorFunction)
159+
DEF_IS_TYPE(isWebAssemblyCompiledModule)
158160
DEF_IS_TYPE(isWeakMap)
159161
DEF_IS_TYPE(isWeakSet)
160162
DEF_IS_TYPE(isSymbolObject)

deps/chakrashim/src/v8value.cc

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,20 @@ bool Value::IsFalse() const {
6464
return this == jsrt::GetFalse();
6565
}
6666

67-
bool Value::IsString() const {
68-
return IsOfType(this, JsValueType::JsString);
67+
#define ISJSVALUETYPE(Type) \
68+
bool Value::Is##Type() const { \
69+
return IsOfType(this, JsValueType::Js##Type); \
6970
}
7071

71-
bool Value::IsSymbol() const {
72-
return IsOfType(this, JsValueType::JsSymbol);
73-
}
74-
75-
bool Value::IsFunction() const {
76-
return IsOfType(this, JsValueType::JsFunction);
77-
}
78-
79-
bool Value::IsArray() const {
80-
return IsOfType(this, JsValueType::JsArray);
81-
}
72+
ISJSVALUETYPE(String)
73+
ISJSVALUETYPE(Symbol)
74+
ISJSVALUETYPE(Function)
75+
ISJSVALUETYPE(Array)
76+
ISJSVALUETYPE(ArrayBuffer)
77+
ISJSVALUETYPE(TypedArray)
78+
ISJSVALUETYPE(DataView)
79+
ISJSVALUETYPE(Boolean)
80+
ISJSVALUETYPE(Number)
8281

8382
bool Value::IsObject() const {
8483
JsValueType type;
@@ -93,14 +92,6 @@ bool Value::IsExternal() const {
9392
return External::IsExternal(this);
9493
}
9594

96-
bool Value::IsArrayBuffer() const {
97-
return IsOfType(this, JsValueType::JsArrayBuffer);
98-
}
99-
100-
bool Value::IsTypedArray() const {
101-
return IsOfType(this, JsValueType::JsTypedArray);
102-
}
103-
10495
#define DEFINE_TYPEDARRAY_CHECK(ArrayType) \
10596
bool Value::Is##ArrayType##Array() const { \
10697
JsTypedArrayType typedArrayType; \
@@ -125,18 +116,6 @@ bool Value::IsArrayBufferView() const {
125116
return IsTypedArray() || IsDataView();
126117
}
127118

128-
bool Value::IsDataView() const {
129-
return IsOfType(this, JsValueType::JsDataView);
130-
}
131-
132-
bool Value::IsBoolean() const {
133-
return IsOfType(this, JsValueType::JsBoolean);
134-
}
135-
136-
bool Value::IsNumber() const {
137-
return IsOfType(this, JsValueType::JsNumber);
138-
}
139-
140119
bool Value::IsInt32() const {
141120
if (!IsNumber()) {
142121
return false;
@@ -175,8 +154,10 @@ if (errorCode != JsNoError) { \
175154
return false; \
176155
} \
177156
return Local<Value>(resultRef)->BooleanValue(); \
178-
} \
157+
}
179158

159+
// Refer to jsrtcachedpropertyidref.inc for the full list
160+
// DEF_IS_TYPE is not structured correctly in order to be used here
180161
IS_TYPE_FUNCTION(IsBooleanObject, isBooleanObject)
181162
IS_TYPE_FUNCTION(IsDate, isDate)
182163
IS_TYPE_FUNCTION(IsMap, isMap)
@@ -192,6 +173,8 @@ IS_TYPE_FUNCTION(IsMapIterator, isMapIterator)
192173
IS_TYPE_FUNCTION(IsSetIterator, isSetIterator)
193174
IS_TYPE_FUNCTION(IsArgumentsObject, isArgumentsObject)
194175
IS_TYPE_FUNCTION(IsGeneratorObject, isGeneratorObject)
176+
IS_TYPE_FUNCTION(IsGeneratorFunction, isGeneratorFunction)
177+
IS_TYPE_FUNCTION(IsWebAssemblyCompiledModule, isWebAssemblyCompiledModule)
195178
IS_TYPE_FUNCTION(IsWeakMap, isWeakMap)
196179
IS_TYPE_FUNCTION(IsWeakSet, isWeakSet)
197180
IS_TYPE_FUNCTION(IsSymbolObject, isSymbolObject)

0 commit comments

Comments
 (0)