mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
builtin.cpp repetitive code cleanup
Merges repetitive code in builtins.cpp by moving X and X.prototype property list to the corresponding builtins_X.h. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I82Q57 Signed-off-by: Onlynagesha <orina_zju@163.com> Change-Id: Ie5c9704bb9aa03b81a04dd5642815447637839ad
This commit is contained in:
parent
83b519a09c
commit
5c09c7621f
@ -30,6 +30,96 @@
|
||||
namespace panda::ecmascript {
|
||||
class JSArray;
|
||||
namespace base {
|
||||
class BuiltinConstantEntry {
|
||||
public:
|
||||
constexpr BuiltinConstantEntry(std::string_view name, JSTaggedValue value) :
|
||||
name_(name), rawTaggedValue_(value.GetRawData()) {}
|
||||
|
||||
static constexpr BuiltinConstantEntry Create(std::string_view name, JSTaggedValue value)
|
||||
{
|
||||
return BuiltinConstantEntry(name, value);
|
||||
}
|
||||
|
||||
constexpr std::string_view GetName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
constexpr JSTaggedValue GetTaggedValue() const
|
||||
{
|
||||
return JSTaggedValue(rawTaggedValue_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string_view name_;
|
||||
JSTaggedType rawTaggedValue_;
|
||||
};
|
||||
|
||||
class BuiltinFunctionEntry {
|
||||
public:
|
||||
static constexpr int LENGTH_BITS_SIZE = 8;
|
||||
static constexpr int BUILTIN_ID_BITS_SIZE = 8;
|
||||
// Assures the bits are enough to represent all builtin stubs.
|
||||
static_assert(kungfu::BuiltinsStubCSigns::NUM_OF_BUILTINS_STUBS <= (1u << BUILTIN_ID_BITS_SIZE));
|
||||
|
||||
using LengthBits = panda::BitField<int, 0, LENGTH_BITS_SIZE>;
|
||||
using BuiltinIdBits = LengthBits::NextField<kungfu::BuiltinsStubCSigns::ID, BUILTIN_ID_BITS_SIZE>;
|
||||
using IsConstructorBit = BuiltinIdBits::NextFlag;
|
||||
using IsAccessorBit = IsConstructorBit::NextFlag;
|
||||
|
||||
template <class... BitFieldArgs>
|
||||
static constexpr BuiltinFunctionEntry Create(std::string_view name, EcmaEntrypoint entrypoint,
|
||||
int length, kungfu::BuiltinsStubCSigns::ID builtinId)
|
||||
{
|
||||
static_assert((std::is_same_v<typename BitFieldArgs::ValueType, bool> && ...),
|
||||
"Only 1-bit fields are available in BitFieldArgs");
|
||||
uint64_t bitfield = 0;
|
||||
bitfield |= LengthBits::Encode(length);
|
||||
bitfield |= BuiltinIdBits::Encode(builtinId);
|
||||
// Traverses BitFieldArgs (IsConstructorBit, IsAccessorBit, etc.)
|
||||
((bitfield |= BitFieldArgs::Encode(true)), ...);
|
||||
return BuiltinFunctionEntry(name, entrypoint, bitfield);
|
||||
}
|
||||
|
||||
constexpr std::string_view GetName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
constexpr EcmaEntrypoint GetEntrypoint() const
|
||||
{
|
||||
return entrypoint_;
|
||||
}
|
||||
|
||||
constexpr int GetLength() const
|
||||
{
|
||||
return LengthBits::Decode(bitfield_);
|
||||
}
|
||||
|
||||
constexpr kungfu::BuiltinsStubCSigns::ID GetBuiltinStubId() const
|
||||
{
|
||||
return BuiltinIdBits::Decode(bitfield_);
|
||||
}
|
||||
|
||||
constexpr bool IsConstructor() const
|
||||
{
|
||||
return IsConstructorBit::Decode(bitfield_);
|
||||
}
|
||||
|
||||
constexpr bool IsAccessor() const
|
||||
{
|
||||
return IsAccessorBit::Decode(bitfield_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string_view name_;
|
||||
EcmaEntrypoint entrypoint_;
|
||||
uint64_t bitfield_;
|
||||
|
||||
constexpr BuiltinFunctionEntry(std::string_view name, EcmaEntrypoint entrypoint, uint64_t bitfield) :
|
||||
name_(name), entrypoint_(entrypoint), bitfield_(bitfield) {}
|
||||
};
|
||||
|
||||
class BuiltinsBase {
|
||||
public:
|
||||
enum ArgsPosition : uint32_t { FIRST = 0, SECOND, THIRD, FOURTH, FIFTH };
|
||||
|
@ -66,6 +66,12 @@ static constexpr size_t INT16_BITS = 16;
|
||||
static constexpr size_t INT8_BITS = 8;
|
||||
static constexpr size_t JS_DTOA_BUF_SIZE = 128;
|
||||
|
||||
// Max number of hexadecimal digits to display an integer
|
||||
static constexpr size_t INT64_HEX_DIGITS = INT64_BITS / 4;
|
||||
static constexpr size_t INT32_HEX_DIGITS = INT32_BITS / 4;
|
||||
static constexpr size_t INT16_HEX_DIGITS = INT16_BITS / 4;
|
||||
static constexpr size_t INT8_HEX_DIGITS = INT8_BITS / 4;
|
||||
|
||||
// help defines for random
|
||||
static constexpr int RIGHT12 = 12;
|
||||
static constexpr int SECONDS_TO_SUBTLE = 1000000;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -28,7 +28,7 @@ namespace panda::ecmascript {
|
||||
struct ErrorParameter {
|
||||
EcmaEntrypoint nativeConstructor{nullptr};
|
||||
EcmaEntrypoint nativeMethod{nullptr};
|
||||
const char *nativePropertyName{nullptr};
|
||||
std::string_view nativePropertyName{};
|
||||
JSType nativeJstype{JSType::INVALID};
|
||||
};
|
||||
|
||||
@ -52,13 +52,13 @@ private:
|
||||
EcmaVM *vm_{nullptr};
|
||||
|
||||
JSHandle<JSFunction> NewBuiltinConstructor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
|
||||
EcmaEntrypoint ctorFunc, const char *name, int length,
|
||||
EcmaEntrypoint ctorFunc, std::string_view name, int length,
|
||||
kungfu::BuiltinsStubCSigns::ID builtinId =
|
||||
kungfu::BuiltinsStubCSigns::INVALID) const;
|
||||
|
||||
JSHandle<JSFunction> NewBuiltinCjsCtor(const JSHandle<GlobalEnv> &env,
|
||||
const JSHandle<JSObject> &prototype, EcmaEntrypoint ctorFunc,
|
||||
const char *name, int length) const;
|
||||
std::string_view name, int length) const;
|
||||
|
||||
JSHandle<JSFunction> NewFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &key,
|
||||
EcmaEntrypoint func, int length,
|
||||
@ -71,7 +71,7 @@ private:
|
||||
const JSHandle<AccessorData> &accessor) const;
|
||||
|
||||
void InitializeCtor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
|
||||
const JSHandle<JSFunction> &ctor, const char *name, int length) const;
|
||||
const JSHandle<JSFunction> &ctor, std::string_view name, int length) const;
|
||||
|
||||
void InitializeGlobalObject(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &globalObject);
|
||||
|
||||
@ -149,9 +149,9 @@ private:
|
||||
|
||||
// for Intl.
|
||||
JSHandle<JSFunction> NewIntlConstructor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
|
||||
EcmaEntrypoint ctorFunc, const char *name, int length);
|
||||
EcmaEntrypoint ctorFunc, std::string_view name, int length);
|
||||
void InitializeIntlCtor(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &prototype,
|
||||
const JSHandle<JSFunction> &ctor, const char *name, int length);
|
||||
const JSHandle<JSFunction> &ctor, std::string_view name, int length);
|
||||
void InitializeIntl(const JSHandle<GlobalEnv> &env, const JSHandle<JSTaggedValue> &objFuncPrototypeValue);
|
||||
void InitializeLocale(const JSHandle<GlobalEnv> &env);
|
||||
void InitializeDateTimeFormat(const JSHandle<GlobalEnv> &env);
|
||||
@ -171,8 +171,8 @@ private:
|
||||
void LazyInitializeDisplayNames(const JSHandle<GlobalEnv> &env) const;
|
||||
void LazyInitializeListFormat(const JSHandle<GlobalEnv> &env) const;
|
||||
|
||||
void GeneralUpdateError(ErrorParameter *error, EcmaEntrypoint constructor, EcmaEntrypoint method, const char *name,
|
||||
JSType type) const;
|
||||
void GeneralUpdateError(ErrorParameter *error, EcmaEntrypoint constructor, EcmaEntrypoint method,
|
||||
std::string_view name, JSType type) const;
|
||||
|
||||
void InitializeSet(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const;
|
||||
void LazyInitializeSet(const JSHandle<GlobalEnv> &env);
|
||||
@ -247,7 +247,7 @@ private:
|
||||
void InitializeGenerator(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &objFuncClass) const;
|
||||
|
||||
JSHandle<JSFunction> InitializeExoticConstructor(const JSHandle<GlobalEnv> &env, EcmaEntrypoint ctorFunc,
|
||||
const char *name, int length);
|
||||
std::string_view name, int length);
|
||||
|
||||
void InitializePromise(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &promiseFuncClass);
|
||||
|
||||
@ -263,7 +263,7 @@ private:
|
||||
|
||||
void InitializeDefaultExportOfScript(const JSHandle<GlobalEnv> &env) const;
|
||||
|
||||
void SetFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, const char *key,
|
||||
void SetFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, std::string_view key,
|
||||
EcmaEntrypoint func, int length, kungfu::BuiltinsStubCSigns::ID builtinId =
|
||||
kungfu::BuiltinsStubCSigns::INVALID) const;
|
||||
|
||||
@ -282,31 +282,38 @@ private:
|
||||
kungfu::BuiltinsStubCSigns::INVALID) const;
|
||||
|
||||
void SetFuncToObjAndGlobal(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &globalObject,
|
||||
const JSHandle<JSObject> &obj, const char *key, EcmaEntrypoint func, int length);
|
||||
const JSHandle<JSObject> &obj, std::string_view key, EcmaEntrypoint func, int length);
|
||||
|
||||
template<int type = JSSymbol::SYMBOL_DEFAULT_TYPE>
|
||||
void SetFunctionAtSymbol(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
|
||||
const JSHandle<JSTaggedValue> &symbol, const char *name, EcmaEntrypoint func,
|
||||
const JSHandle<JSTaggedValue> &symbol, std::string_view name, EcmaEntrypoint func,
|
||||
int length) const;
|
||||
|
||||
void SetStringTagSymbol(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, const char *key) const;
|
||||
JSHandle<JSTaggedValue> CreateGetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func, const char *name,
|
||||
int length) const;
|
||||
void SetStringTagSymbol(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj,
|
||||
std::string_view key) const;
|
||||
JSHandle<JSTaggedValue> CreateGetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
|
||||
std::string_view name, int length) const;
|
||||
JSHandle<JSTaggedValue> CreateGetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
|
||||
JSHandle<JSTaggedValue> key, int length) const;
|
||||
|
||||
void SetConstant(const JSHandle<JSObject> &obj, const char *key, JSTaggedValue value) const;
|
||||
void SetConstant(const JSHandle<JSObject> &obj, std::string_view key, JSTaggedValue value) const;
|
||||
|
||||
void SetGlobalThis(const JSHandle<JSObject> &obj, const char *key, const JSHandle<JSTaggedValue> &globalValue);
|
||||
void SetGlobalThis(const JSHandle<JSObject> &obj, std::string_view key,
|
||||
const JSHandle<JSTaggedValue> &globalValue);
|
||||
|
||||
void SetAttribute(const JSHandle<JSObject> &obj, const char *key, const char *value) const;
|
||||
void SetAttribute(const JSHandle<JSObject> &obj, std::string_view key, std::string_view value) const;
|
||||
|
||||
void SetNoneAttributeProperty(const JSHandle<JSObject> &obj, const char *key,
|
||||
void SetNoneAttributeProperty(const JSHandle<JSObject> &obj, std::string_view key,
|
||||
const JSHandle<JSTaggedValue> &value) const;
|
||||
|
||||
void StrictModeForbiddenAccessCallerArguments(const JSHandle<GlobalEnv> &env,
|
||||
const JSHandle<JSObject> &prototype) const;
|
||||
|
||||
JSHandle<JSTaggedValue> CreateSetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func, const char *name,
|
||||
int length);
|
||||
JSHandle<JSTaggedValue> CreateSetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
|
||||
std::string_view name, int length) const;
|
||||
JSHandle<JSTaggedValue> CreateSetter(const JSHandle<GlobalEnv> &env, EcmaEntrypoint func,
|
||||
JSHandle<JSTaggedValue> key, int length) const;
|
||||
|
||||
void SetArgumentsSharedAccessor(const JSHandle<GlobalEnv> &env);
|
||||
void SetAccessor(const JSHandle<JSObject> &obj, const JSHandle<JSTaggedValue> &key,
|
||||
const JSHandle<JSTaggedValue> &getter, const JSHandle<JSTaggedValue> &setter) const;
|
||||
@ -316,10 +323,12 @@ private:
|
||||
void InitializeGlobalRegExp(JSHandle<JSObject> &obj) const;
|
||||
// Using to initialize jsapi container
|
||||
JSHandle<JSObject> InitializeArkPrivate(const JSHandle<GlobalEnv> &env) const;
|
||||
void SetConstantObject(const JSHandle<JSObject> &obj, const char *key, JSHandle<JSTaggedValue> &value) const;
|
||||
void SetFrozenFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, const char *key,
|
||||
void SetConstantObject(const JSHandle<JSObject> &obj, std::string_view key,
|
||||
JSHandle<JSTaggedValue> &value) const;
|
||||
void SetFrozenFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSObject> &obj, std::string_view key,
|
||||
EcmaEntrypoint func, int length) const;
|
||||
void SetNonConstantObject(const JSHandle<JSObject> &obj, const char *key, JSHandle<JSTaggedValue> &value) const;
|
||||
void SetNonConstantObject(const JSHandle<JSObject> &obj, std::string_view key,
|
||||
JSHandle<JSTaggedValue> &value) const;
|
||||
|
||||
friend class builtins::BuiltinsLazyCallback;
|
||||
};
|
||||
|
@ -19,6 +19,39 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/js_thread.h"
|
||||
|
||||
// List of functions in ArkTools, extension of ArkTS engine.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsArkTools::func refers to the native implementation of ArkTools[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_ARK_TOOLS_FUNCTIONS_COMMON(V) \
|
||||
V("compareHClass", CompareHClass, 2, INVALID) \
|
||||
V("dumpHClass", DumpHClass, 1, INVALID) \
|
||||
V("excutePendingJob", ExcutePendingJob, 0, INVALID) \
|
||||
V("forceFullGC", ForceFullGC, 0, INVALID) \
|
||||
V("getHClass", GetHClass, 1, INVALID) \
|
||||
V("getLexicalEnv", GetLexicalEnv, 1, INVALID) \
|
||||
V("hasTSSubtyping", HasTSSubtyping, 1, INVALID) \
|
||||
V("hiddenStackSourceFile", HiddenStackSourceFile, 0, INVALID) \
|
||||
V("isNotHoleProperty", IsNotHoleProperty, 2, INVALID) \
|
||||
V("isPrototype", IsPrototype, 1, INVALID) \
|
||||
V("isRegExpReplaceDetectorValid", IsRegExpReplaceDetectorValid, 0, INVALID) \
|
||||
V("isTSHClass", IsTSHClass, 1, INVALID) \
|
||||
V("print", ObjectDump, 0, INVALID) \
|
||||
V("removeAOTFlag", RemoveAOTFlag, 1, INVALID) \
|
||||
V("timeInUs", TimeInUs, 0, INVALID)
|
||||
|
||||
#ifdef ECMASCRIPT_SUPPORT_CPUPROFILER
|
||||
#define BUILTIN_ARK_TOOLS_FUNCTIONS_CPUPROFILER(V) \
|
||||
V("startCpuProf", StartCpuProfiler, 0, INVALID) \
|
||||
V("stopCpuProf", StopCpuProfiler, 0, INVALID)
|
||||
#else
|
||||
#define BUILTIN_ARK_TOOLS_FUNCTIONS_CPUPROFILER(V) // Nothing
|
||||
#endif
|
||||
|
||||
#define BUILTIN_ARK_TOOLS_FUNCTIONS(V) \
|
||||
BUILTIN_ARK_TOOLS_FUNCTIONS_COMMON(V) \
|
||||
BUILTIN_ARK_TOOLS_FUNCTIONS_CPUPROFILER(V)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsArkTools : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -64,6 +97,20 @@ public:
|
||||
static JSTaggedValue IsRegExpReplaceDetectorValid(EcmaRuntimeCallInfo *info);
|
||||
|
||||
static JSTaggedValue TimeInUs(EcmaRuntimeCallInfo *info);
|
||||
|
||||
static Span<const base::BuiltinFunctionEntry> GetArkToolsFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(ARK_TOOLS_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTINS_ARK_TOOLS_FUNCTION_ENTRY(name, method, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsArkTools::method, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array ARK_TOOLS_FUNCTIONS = {
|
||||
BUILTIN_ARK_TOOLS_FUNCTIONS(BUILTINS_ARK_TOOLS_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTINS_ARK_TOOLS_FUNCTION_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
|
||||
|
@ -18,6 +18,99 @@
|
||||
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
|
||||
// List of functions in Array, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsArray::func refers to the native implementation of Array[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_ARRAY_FUNCTIONS(V) \
|
||||
/* Array.from ( items [ , mapfn [ , thisArg ] ] ) */ \
|
||||
V("from", From, 1, INVALID) \
|
||||
/* Array.isArray ( arg ) */ \
|
||||
V("isArray", IsArray, 1, INVALID) \
|
||||
/* Array.of ( ...items ) */ \
|
||||
V("of", Of, 0, INVALID)
|
||||
|
||||
// List of functions in Array.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsArray::func refers to the native implementation of Array.prototype[name].
|
||||
#define BUILTIN_ARRAY_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* Array.prototype.at ( index ) */ \
|
||||
V("at", At, 1, INVALID) \
|
||||
/* Array.prototype.concat ( ...items ) */ \
|
||||
V("concat", Concat, 1, ArrayConcat) \
|
||||
/* Array.prototype.copyWithin ( target, start [ , end ] ) */ \
|
||||
V("copyWithin", CopyWithin, 2, INVALID) \
|
||||
/* Array.prototype.entries ( ) */ \
|
||||
V("entries", Entries, 0, INVALID) \
|
||||
/* Array.prototype.every ( callbackfn [ , thisArg ] ) */ \
|
||||
V("every", Every, 1, INVALID) \
|
||||
/* Array.prototype.fill ( value [ , start [ , end ] ] ) */ \
|
||||
V("fill", Fill, 1, INVALID) \
|
||||
/* Array.prototype.filter ( callbackfn [ , thisArg ] ) */ \
|
||||
V("filter", Filter, 1, ArrayFilter) \
|
||||
/* Array.prototype.find ( predicate [ , thisArg ] ) */ \
|
||||
V("find", Find, 1, INVALID) \
|
||||
/* Array.prototype.findIndex ( predicate [ , thisArg ] ) */ \
|
||||
V("findIndex", FindIndex, 1, INVALID) \
|
||||
/* Array.prototype.findLast ( predicate [ , thisArg ] ) */ \
|
||||
V("findLast", FindLast, 1, INVALID) \
|
||||
/* Array.prototype.findLastIndex ( predicate [ , thisArg ] ) */ \
|
||||
V("findLastIndex", FindLastIndex, 1, INVALID) \
|
||||
/* Array.prototype.flat ( [ depth ] ) */ \
|
||||
V("flat", Flat, 0, INVALID) \
|
||||
/* Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) */ \
|
||||
V("flatMap", FlatMap, 1, INVALID) \
|
||||
/* Array.prototype.forEach ( callbackfn [ , thisArg ] ) */ \
|
||||
V("forEach", ForEach, 1, ArrayForEach) \
|
||||
/* Array.prototype.includes ( searchElement [ , fromIndex ] ) */ \
|
||||
V("includes", Includes, 1, INVALID) \
|
||||
/* Array.prototype.indexOf ( searchElement [ , fromIndex ] ) */ \
|
||||
V("indexOf", IndexOf, 1, ArrayIndexOf) \
|
||||
/* Array.prototype.join ( separator ) */ \
|
||||
V("join", Join, 1, INVALID) \
|
||||
/* Array.prototype.keys ( ) */ \
|
||||
V("keys", Keys, 0, INVALID) \
|
||||
/* Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) */ \
|
||||
V("lastIndexOf", LastIndexOf, 1, ArrayLastIndexOf) \
|
||||
/* Array.prototype.map ( callbackfn [ , thisArg ] ) */ \
|
||||
V("map", Map, 1, INVALID) \
|
||||
/* Array.prototype.pop ( ) */ \
|
||||
V("pop", Pop, 0, INVALID) \
|
||||
/* Array.prototype.push ( ...items ) */ \
|
||||
V("push", Push, 1, ArrayPush) \
|
||||
/* Array.prototype.reduce ( callbackfn [ , initialValue ] ) */ \
|
||||
V("reduce", Reduce, 1, INVALID) \
|
||||
/* Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) */ \
|
||||
V("reduceRight", ReduceRight, 1, INVALID) \
|
||||
/* Array.prototype.reverse ( ) */ \
|
||||
V("reverse", Reverse, 0, ArrayReverse) \
|
||||
/* Array.prototype.shift ( ) */ \
|
||||
V("shift", Shift, 0, INVALID) \
|
||||
/* Array.prototype.slice ( start, end ) */ \
|
||||
V("slice", Slice, 2, ArraySlice) \
|
||||
/* Array.prototype.some ( callbackfn [ , thisArg ] ) */ \
|
||||
V("some", Some, 1, INVALID) \
|
||||
/* Array.prototype.sort ( comparefn ) */ \
|
||||
V("sort", Sort, 1, SORT) \
|
||||
/* Array.prototype.splice ( start, deleteCount, ...items ) */ \
|
||||
V("splice", Splice, 2, INVALID) \
|
||||
/* Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleString", ToLocaleString, 0, INVALID) \
|
||||
/* Array.prototype.toReversed ( ) */ \
|
||||
V("toReversed", ToReversed, 0, INVALID) \
|
||||
/* Array.prototype.toSorted ( comparefn ) */ \
|
||||
V("toSorted", ToSorted, 1, INVALID) \
|
||||
/* Array.prototype.toSpliced ( start, skipCount, ...items ) */ \
|
||||
V("toSpliced", ToSpliced, 2, INVALID) \
|
||||
/* Array.prototype.toString ( ) */ \
|
||||
V("toString", ToString, 0, INVALID) \
|
||||
/* Array.prototype.unshift ( ...items ) */ \
|
||||
V("unshift", Unshift, 1, INVALID) \
|
||||
/* Array.prototype.values ( ) */ \
|
||||
V("values", Values, 0, INVALID) \
|
||||
/* Array.prototype.with ( index, value ) */ \
|
||||
V("with", With, 2, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
static constexpr uint8_t INDEX_TWO = 2;
|
||||
static constexpr uint8_t INDEX_THREE = 3;
|
||||
@ -116,7 +209,30 @@ public:
|
||||
// 23.1.3.35 Array.prototype.toSpliced ( start, skipCount, ...items )
|
||||
static JSTaggedValue ToSpliced(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetArrayFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(ARRAY_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetArrayPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(ARRAY_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_ARRAY_FUNCTION_ENTRY(name, method, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsArray::method, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array ARRAY_FUNCTIONS = {
|
||||
BUILTIN_ARRAY_FUNCTIONS(BUILTIN_ARRAY_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array ARRAY_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_ARRAY_PROTOTYPE_FUNCTIONS(BUILTIN_ARRAY_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_ARRAY_FUNCTION_ENTRY
|
||||
|
||||
static JSTaggedValue IndexOfStable(
|
||||
EcmaRuntimeCallInfo *argv, JSThread *thread, const JSHandle<JSTaggedValue> &thisHandle);
|
||||
static JSTaggedValue IndexOfSlowPath(
|
||||
|
@ -20,6 +20,38 @@
|
||||
#include "ecmascript/js_dataview.h"
|
||||
#include "ecmascript/waiter_list.h"
|
||||
|
||||
// List of functions in Atomics.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsAtomics::func refers to the native implementation of Atomics[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
// The following functions are not implemented yet:
|
||||
// - Atomics.waitAsync ( typedArray, index, value, timeout )
|
||||
#define BUILTIN_ATOMICS_FUNCTIONS(V) \
|
||||
/* Atomics.add ( typedArray, index, value ) */ \
|
||||
V("add", Add, 3, INVALID) \
|
||||
/* Atomics.and ( typedArray, index, value ) */ \
|
||||
V("and", And, 3, INVALID) \
|
||||
/* Atomics.compareExchange ( typedArray, index, expectedValue, replacementValue ) */ \
|
||||
V("compareExchange", CompareExchange, 4, INVALID) \
|
||||
/* Atomics.exchange ( typedArray, index, value ) */ \
|
||||
V("exchange", Exchange, 3, INVALID) \
|
||||
/* Atomics.isLockFree ( size ) */ \
|
||||
V("isLockFree", IsLockFree, 1, INVALID) \
|
||||
/* Atomics.load ( typedArray, index ) */ \
|
||||
V("load", Load, 2, INVALID) \
|
||||
/* Atomics.notify ( typedArray, index, count ) */ \
|
||||
V("notify", Notify, 3, INVALID) \
|
||||
/* Atomics.or ( typedArray, index, value ) */ \
|
||||
V("or", Or, 3, INVALID) \
|
||||
/* Atomics.store ( typedArray, index, value ) */ \
|
||||
V("store", Store, 3, INVALID) \
|
||||
/* Atomics.sub ( typedArray, index, value ) */ \
|
||||
V("sub", Sub, 3, INVALID) \
|
||||
/* Atomics.wait ( typedArray, index, value, timeout ) */ \
|
||||
V("wait", Wait, 4, INVALID) \
|
||||
/* Atomics.xor ( typedArray, index, value ) */ \
|
||||
V("xor", Xor, 3, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
enum class WaitResult: uint8_t {OK = 0, NOT_EQ, TIME_OUT};
|
||||
|
||||
@ -50,7 +82,20 @@ public:
|
||||
// 25.4.13 Atomics.xor ( typedArray, index, value )
|
||||
static JSTaggedValue Xor(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
static Span<const base::BuiltinFunctionEntry> GetAtomicsFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(ATOMICS_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTINS_ATOMICS_FUNCTION_ENTRY(name, method, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsAtomics::method, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array ATOMICS_FUNCTIONS = {
|
||||
BUILTIN_ATOMICS_FUNCTIONS(BUILTINS_ATOMICS_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTINS_ATOMICS_FUNCTION_ENTRY
|
||||
|
||||
static uint32_t Signal(JSHandle<JSTaggedValue> &arrayBuffer, const size_t &index, double wakeCount);
|
||||
template <typename T>
|
||||
static WaitResult DoWait(JSThread *thread, JSHandle<JSTaggedValue> &arrayBuffer,
|
||||
|
@ -19,6 +19,40 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/js_dataview.h"
|
||||
|
||||
// List of functions in DataView, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsDataView::func refers to the native implementation of DataView.prototype[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_DATA_VIEW_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* For %Type% of 1 byte: */ \
|
||||
/* DataView.prototype.get%Type% ( byteOffset ) */ \
|
||||
/* For %Type% of 2 or more bytes: */ \
|
||||
/* DataView.prototype.get%Type% ( byteOffset [ , littleEndian ] ) */ \
|
||||
V("getFloat32", GetFloat32, 1, INVALID) \
|
||||
V("getFloat64", GetFloat64, 1, INVALID) \
|
||||
V("getInt8", GetInt8, 1, INVALID) \
|
||||
V("getInt16", GetInt16, 1, INVALID) \
|
||||
V("getInt32", GetInt32, 1, INVALID) \
|
||||
V("getBigInt64", GetBigInt64, 1, INVALID) \
|
||||
V("getUint16", GetUint16, 1, INVALID) \
|
||||
V("getUint32", GetUint32, 1, INVALID) \
|
||||
V("getUint8", GetUint8, 1, INVALID) \
|
||||
V("getBigUint64", GetBigUint64, 1, INVALID) \
|
||||
/* For %Type% of 1 bytes: */ \
|
||||
/* DataView.prototype.setInt8 ( byteOffset, value ) */ \
|
||||
/* For %Type% of 2 or more bytes: */ \
|
||||
/* DataView.prototype.setInt16 ( byteOffset, value [ , littleEndian ] ) */ \
|
||||
V("setFloat32", SetFloat32, 2, INVALID) \
|
||||
V("setFloat64", SetFloat64, 2, INVALID) \
|
||||
V("setInt8", SetInt8, 2, INVALID) \
|
||||
V("setInt16", SetInt16, 2, INVALID) \
|
||||
V("setInt32", SetInt32, 2, INVALID) \
|
||||
V("setBigInt64", SetBigInt64, 2, INVALID) \
|
||||
V("setUint8", SetUint8, 2, INVALID) \
|
||||
V("setUint16", SetUint16, 2, INVALID) \
|
||||
V("setUint32", SetUint32, 2, INVALID) \
|
||||
V("setBigUint64", SetBigUint64, 2, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
using DataViewType = ecmascript::DataViewType;
|
||||
class BuiltinsDataView : public base::BuiltinsBase {
|
||||
@ -72,7 +106,22 @@ public:
|
||||
// 25.3.4.16 DataView.prototype.setBigUint64 ( byteOffset, value [ , littleEndian ] )
|
||||
static JSTaggedValue SetBigUint64(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetDataViewPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(DATA_VIEW_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_DATA_VIEW_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsDataView::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array DATA_VIEW_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_DATA_VIEW_PROTOTYPE_FUNCTIONS(BUILTIN_DATA_VIEW_FUNCTION_ENTRY)
|
||||
};
|
||||
|
||||
#undef BUILTIN_DATA_VIEW_FUNCTION_ENTRY
|
||||
|
||||
// 24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
static JSTaggedValue GetViewValue(JSThread *thread, const JSHandle<JSTaggedValue> &view,
|
||||
const JSHandle<JSTaggedValue> &requestIndex,
|
||||
|
@ -19,9 +19,114 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/js_date.h"
|
||||
|
||||
// List of functions in Date, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsDate::func refers to the native implementation of Date[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_DATE_FUNCTIONS(V) \
|
||||
/* Date.now ( ) */ \
|
||||
V("now", Now, 0, INVALID) \
|
||||
/* Date.parse ( string ) */ \
|
||||
V("parse", Parse, 1, INVALID) \
|
||||
/* Date.UTC ( year [ , month [ , date [ , hours [ , minutes [ , seconds [ , ms ] ] ] ] ] ] ) */ \
|
||||
V("UTC", UTC, ::panda::ecmascript::builtins::BuiltinsDate::UTC_LENGTH, INVALID)
|
||||
|
||||
// List of functions in Date.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsDate::func refers to the native implementation of Date.prototype[name].
|
||||
#define BUILTIN_DATE_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* Date.prototype.getDate ( ) */ \
|
||||
V("getDate", GetDate, 0, INVALID) \
|
||||
/* Date.prototype.getDay ( ) */ \
|
||||
V("getDay", GetDay, 0, INVALID) \
|
||||
/* Date.prototype.getFullYear ( ) */ \
|
||||
V("getFullYear", GetFullYear, 0, INVALID) \
|
||||
/* Date.prototype.getHours ( ) */ \
|
||||
V("getHours", GetHours, 0, INVALID) \
|
||||
/* Date.prototype.getMilliseconds ( ) */ \
|
||||
V("getMilliseconds", GetMilliseconds, 0, INVALID) \
|
||||
/* Date.prototype.getMinutes ( ) */ \
|
||||
V("getMinutes", GetMinutes, 0, INVALID) \
|
||||
/* Date.prototype.getMonth ( ) */ \
|
||||
V("getMonth", GetMonth, 0, INVALID) \
|
||||
/* Date.prototype.getSeconds ( ) */ \
|
||||
V("getSeconds", GetSeconds, 0, INVALID) \
|
||||
/* Date.prototype.getTime ( ) */ \
|
||||
V("getTime", GetTime, 0, INVALID) \
|
||||
/* Date.prototype.getTimezoneOffset ( ) */ \
|
||||
V("getTimezoneOffset", GetTimezoneOffset, 0, INVALID) \
|
||||
/* Date.prototype.getUTCDate ( ) */ \
|
||||
V("getUTCDate", GetUTCDate, 0, INVALID) \
|
||||
/* Date.prototype.getUTCDay ( ) */ \
|
||||
V("getUTCDay", GetUTCDay, 0, INVALID) \
|
||||
/* Date.prototype.getUTCFullYear ( ) */ \
|
||||
V("getUTCFullYear", GetUTCFullYear, 0, INVALID) \
|
||||
/* Date.prototype.getUTCHours ( ) */ \
|
||||
V("getUTCHours", GetUTCHours, 0, INVALID) \
|
||||
/* Date.prototype.getUTCMilliseconds ( ) */ \
|
||||
V("getUTCMilliseconds", GetUTCMilliseconds, 0, INVALID) \
|
||||
/* Date.prototype.getUTCMinutes ( ) */ \
|
||||
V("getUTCMinutes", GetUTCMinutes, 0, INVALID) \
|
||||
/* Date.prototype.getUTCMonth ( ) */ \
|
||||
V("getUTCMonth", GetUTCMonth, 0, INVALID) \
|
||||
/* Date.prototype.getUTCSeconds ( ) */ \
|
||||
V("getUTCSeconds", GetUTCSeconds, 0, INVALID) \
|
||||
/* Date.prototype.setDate ( date ) */ \
|
||||
V("setDate", SetDate, 1, INVALID) \
|
||||
/* Date.prototype.setFullYear ( year [ , month [ , date ] ] ) */ \
|
||||
V("setFullYear", SetFullYear, 3, INVALID) \
|
||||
/* Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] ) */ \
|
||||
V("setHours", SetHours, 4, INVALID) \
|
||||
/* Date.prototype.setMilliseconds ( ms ) */ \
|
||||
V("setMilliseconds", SetMilliseconds, 1, INVALID) \
|
||||
/* Date.prototype.setMinutes ( min [ , sec [ , ms ] ] ) */ \
|
||||
V("setMinutes", SetMinutes, 3, INVALID) \
|
||||
/* Date.prototype.setMonth ( month [ , date ] ) */ \
|
||||
V("setMonth", SetMonth, 2, INVALID) \
|
||||
/* Date.prototype.setSeconds ( sec [ , ms ] ) */ \
|
||||
V("setSeconds", SetSeconds, 2, INVALID) \
|
||||
/* Date.prototype.setTime ( time ) */ \
|
||||
V("setTime", SetTime, 1, INVALID) \
|
||||
/* Date.prototype.setUTCDate ( date ) */ \
|
||||
V("setUTCDate", SetUTCDate, 1, INVALID) \
|
||||
/* Date.prototype.setUTCFullYear ( year [ , month [ , date ] ] ) */ \
|
||||
V("setUTCFullYear", SetUTCFullYear, 3, INVALID) \
|
||||
/* Date.prototype.setUTCHours ( hour [ , min [ , sec [ , ms ] ] ] ) */ \
|
||||
V("setUTCHours", SetUTCHours, 4, INVALID) \
|
||||
/* Date.prototype.setUTCMilliseconds ( ms ) */ \
|
||||
V("setUTCMilliseconds", SetUTCMilliseconds, 1, INVALID) \
|
||||
/* Date.prototype.setUTCMinutes ( min [ , sec [ , ms ] ] ) */ \
|
||||
V("setUTCMinutes", SetUTCMinutes, 3, INVALID) \
|
||||
/* Date.prototype.setUTCMonth ( month [ , date ] ) */ \
|
||||
V("setUTCMonth", SetUTCMonth, 2, INVALID) \
|
||||
/* Date.prototype.setUTCSeconds ( sec [ , ms ] ) */ \
|
||||
V("setUTCSeconds", SetUTCSeconds, 2, INVALID) \
|
||||
/* Date.prototype.toDateString ( ) */ \
|
||||
V("toDateString", ToDateString, 0, INVALID) \
|
||||
/* Date.prototype.toISOString ( ) */ \
|
||||
V("toISOString", ToISOString, 0, INVALID) \
|
||||
/* Date.prototype.toJSON ( key ) */ \
|
||||
V("toJSON", ToJSON, 1, INVALID) \
|
||||
/* Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleDateString", ToLocaleDateString, 0, INVALID) \
|
||||
/* Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleString", ToLocaleString, 0, INVALID) \
|
||||
/* Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleTimeString", ToLocaleTimeString, 0, INVALID) \
|
||||
/* Date.prototype.toString ( ) */ \
|
||||
V("toString", ToString, 0, INVALID) \
|
||||
/* Date.prototype.toTimeString ( ) */ \
|
||||
V("toTimeString", ToTimeString, 0, INVALID) \
|
||||
/* Date.prototype.toUTCString ( ) */ \
|
||||
V("toUTCString", ToUTCString, 0, INVALID) \
|
||||
/* Date.prototype.valueOf ( ) */ \
|
||||
V("valueOf", ValueOf, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsDate : public base::BuiltinsBase {
|
||||
public:
|
||||
static constexpr int UTC_LENGTH = 7;
|
||||
|
||||
// 20.4.2 The Date Constructor
|
||||
static JSTaggedValue DateConstructor(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
@ -165,7 +270,30 @@ public:
|
||||
// 20.4.4.45 Date.prototype [ @@toPrimitive ]
|
||||
static JSTaggedValue ToPrimitive(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetDateFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(DATE_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetDatePrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(DATE_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_DATE_FUNCTION_ENTRY(name, func, length, builtinId) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsDate::func, length, kungfu::BuiltinsStubCSigns::builtinId),
|
||||
|
||||
static constexpr std::array DATE_FUNCTIONS = {
|
||||
BUILTIN_DATE_FUNCTIONS(BUILTIN_DATE_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array DATE_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_DATE_PROTOTYPE_FUNCTIONS(BUILTIN_DATE_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_DATE_FUNCTION_ENTRY
|
||||
|
||||
// definition for set data code.
|
||||
static constexpr uint32_t CODE_SET_DATE = 0x32;
|
||||
static constexpr uint32_t CODE_SET_MILLISECONDS = 0x76;
|
||||
|
@ -19,6 +19,73 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/js_thread.h"
|
||||
|
||||
#define BUILTIN_GLOBAL_CONSTANTS(V) \
|
||||
V("Infinity", INFINITY_VALUE) \
|
||||
V("NaN", NAN_VALUE) \
|
||||
V("undefined", UNDEFINED_VALUE)
|
||||
|
||||
// List of functions in the global object.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsGlobal::func refers to the native implementation of globalThis[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
// The following global object properties are not implemented yet:
|
||||
// - Encode ( string, extraUnescaped )
|
||||
// - Decode ( string, preserveEscapeSet )
|
||||
// - ParseHexOctet ( string, position )
|
||||
// The following global object properties are not listed here:
|
||||
// - parseFloat ( string ), listed in builtins_number.h instead.
|
||||
// - parseInt ( string ), listed in builtins_number.h instead.
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_COMMON(V) \
|
||||
/* decodeURI ( encodedURI ) */ \
|
||||
V("decodeURI", DecodeURI, 1, INVALID) \
|
||||
/* decodeURIComponent ( encodedURIComponent ) */ \
|
||||
V("decodeURIComponent", DecodeURIComponent, 1, INVALID) \
|
||||
/* encodeURI ( uri ) */ \
|
||||
V("encodeURI", EncodeURI, 1, INVALID) \
|
||||
/* encodeURIComponent ( uriComponent ) */ \
|
||||
V("encodeURIComponent", EncodeURIComponent, 1, INVALID) \
|
||||
/* escape ( string ), defined in B.2.1 */ \
|
||||
V("escape", Escape, 1, INVALID) \
|
||||
/* eval ( x ), which is NOT supported in ArkTS engine */ \
|
||||
V("eval", NotSupportEval, 1, INVALID) \
|
||||
/* isFinite ( number ) */ \
|
||||
V("isFinite", IsFinite, 1, INVALID) \
|
||||
/* isNaN ( number ) */ \
|
||||
V("isNaN", IsNaN, 1, INVALID) \
|
||||
/* unescape ( string )*/ \
|
||||
V("unescape", Unescape, 1, INVALID) \
|
||||
/* The following are ArkTS extensions */ \
|
||||
V("markModuleCollectable", MarkModuleCollectable, 0, INVALID) \
|
||||
V("print", PrintEntrypoint, 0, INVALID)
|
||||
|
||||
#if ECMASCRIPT_ENABLE_RUNTIME_STAT
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_RUNTIME_STAT(V) \
|
||||
V("startRuntimeStat", StartRuntimeStat, 0, INVALID) \
|
||||
V("stopRuntimeStat", StopRuntimeStat, 0, INVALID)
|
||||
#else
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_RUNTIME_STAT(V) // Nothing
|
||||
#endif
|
||||
|
||||
#if ECMASCRIPT_ENABLE_OPT_CODE_PROFILER
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_OPT_CODE_PROFILER(V) \
|
||||
V("printOptStat", PrintOptStat, 0, INVALID)
|
||||
#else
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_OPT_CODE_PROFILER(V) // Nothing
|
||||
#endif
|
||||
|
||||
#if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_FUNCTION_CALL_TIMER(V) \
|
||||
V("printFunctionCallStat", PrintFunctionCallStat, 0, INVALID)
|
||||
#else
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS_FUNCTION_CALL_TIMER(V) // Nothing
|
||||
#endif
|
||||
|
||||
#define BUILTIN_GLOBAL_FUNCTIONS(V) \
|
||||
BUILTIN_GLOBAL_FUNCTIONS_COMMON(V) \
|
||||
BUILTIN_GLOBAL_FUNCTIONS_RUNTIME_STAT(V) \
|
||||
BUILTIN_GLOBAL_FUNCTIONS_OPT_CODE_PROFILER(V) \
|
||||
BUILTIN_GLOBAL_FUNCTIONS_FUNCTION_CALL_TIMER(V)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
static constexpr uint8_t BIT_MASK = 0x0F;
|
||||
static constexpr uint8_t BIT_MASK_FF = 0xFF;
|
||||
@ -35,6 +102,10 @@ enum class Placement {
|
||||
|
||||
class BuiltinsGlobal : public base::BuiltinsBase {
|
||||
public:
|
||||
static const inline JSTaggedValue INFINITY_VALUE = JSTaggedValue(base::POSITIVE_INFINITY);
|
||||
static const inline JSTaggedValue NAN_VALUE = JSTaggedValue(base::NAN_VALUE);
|
||||
static const inline JSTaggedValue UNDEFINED_VALUE = JSTaggedValue::Undefined();
|
||||
|
||||
// 18.2.1
|
||||
static JSTaggedValue NotSupportEval(EcmaRuntimeCallInfo *msg);
|
||||
// 18.2.2
|
||||
@ -68,7 +139,31 @@ public:
|
||||
// B.2.1.2 unescape ( string )
|
||||
static JSTaggedValue Unescape(EcmaRuntimeCallInfo *msg);
|
||||
|
||||
static Span<const base::BuiltinConstantEntry> GetGlobalConstants()
|
||||
{
|
||||
return Span<const base::BuiltinConstantEntry>(GLOBAL_CONSTANTS);
|
||||
}
|
||||
|
||||
static Span<const base::BuiltinFunctionEntry> GetGlobalFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(GLOBAL_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_GLOBAL_CONSTANT_ENTRY(name, var) \
|
||||
base::BuiltinConstantEntry::Create(name, BuiltinsGlobal::var),
|
||||
#define BUILTIN_GLOBAL_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsGlobal::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static inline std::array GLOBAL_CONSTANTS = {
|
||||
BUILTIN_GLOBAL_CONSTANTS(BUILTIN_GLOBAL_CONSTANT_ENTRY)
|
||||
};
|
||||
static constexpr std::array GLOBAL_FUNCTIONS = {
|
||||
BUILTIN_GLOBAL_FUNCTIONS(BUILTIN_GLOBAL_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_GLOBAL_CONSTANT_ENTRY
|
||||
#undef BUILTIN_GLOBAL_FUNCTION_ENTRY
|
||||
|
||||
static void PrintString(JSThread *thread, EcmaString *string);
|
||||
static void PrintValue(int64_t value, int64_t tag);
|
||||
static JSTaggedValue Encode(JSThread *thread, const JSHandle<EcmaString> &str, judgURIFunc IsInURISet);
|
||||
|
@ -19,6 +19,30 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/ecma_runtime_call_info.h"
|
||||
|
||||
// List of functions in Map.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsMap::func refers to the native implementation of Map.prototype[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_MAP_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* Map.prototype.clear ( ) */ \
|
||||
V("clear", Clear, 0, INVALID) \
|
||||
/* Map.prototype.delete ( key ) */ \
|
||||
V("delete", Delete, 1, MapDelete) \
|
||||
/* Map.prototype.entries ( ) */ \
|
||||
V("entries", Entries, 0, INVALID) \
|
||||
/* Map.prototype.forEach ( callbackfn [ , thisArg ] ) */ \
|
||||
V("forEach", ForEach, 1, MapForEach) \
|
||||
/* Map.prototype.get ( key ) */ \
|
||||
V("get", Get, 1, INVALID) \
|
||||
/* Map.prototype.has ( key ) */ \
|
||||
V("has", Has, 1, INVALID) \
|
||||
/* Map.prototype.keys ( ) */ \
|
||||
V("keys", Keys, 0, INVALID) \
|
||||
/* Map.prototype.set ( key, value ) */ \
|
||||
V("set", Set, 2, MapSet) \
|
||||
/* Map.prototype.values ( ) */ \
|
||||
V("values", Values, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsMap : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -51,6 +75,22 @@ public:
|
||||
static JSTaggedValue AddEntriesFromIterable(JSThread *thread, const JSHandle<JSObject> &target,
|
||||
const JSHandle<JSTaggedValue> &iterable,
|
||||
const JSHandle<JSTaggedValue> &adder, ObjectFactory *factory);
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetMapPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(MAP_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_MAP_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsMap::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array MAP_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_MAP_PROTOTYPE_FUNCTIONS(BUILTIN_MAP_FUNCTION_ENTRY)
|
||||
};
|
||||
|
||||
#undef BUILTIN_MAP_FUNCTION_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
#endif // ECMASCRIPT_BUILTINS_BUILTINS_MAP_H
|
||||
|
@ -18,6 +18,58 @@
|
||||
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
|
||||
// List of constants in Math, excluding '@@' internal properties.
|
||||
#define BUILTIN_MATH_CONSTANTS(V) \
|
||||
V(E) \
|
||||
V(LN10) \
|
||||
V(LN2) \
|
||||
V(LOG10E) \
|
||||
V(LOG2E) \
|
||||
V(PI) \
|
||||
V(SQRT1_2) \
|
||||
V(SQRT2)
|
||||
|
||||
// List of functions in Math.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsMath::func refers to the native implementation of Math[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_MATH_FUNCTIONS(V) \
|
||||
V("abs", Abs, 1, ABS) /* Math.abs ( x ) */ \
|
||||
V("acos", Acos, 1, ACOS) /* Math.acos ( x ) */ \
|
||||
V("acosh", Acosh, 1, INVALID) /* Math.acosh ( x ) */ \
|
||||
V("asin", Asin, 1, INVALID) /* Math.asin ( x ) */ \
|
||||
V("asinh", Asinh, 1, INVALID) /* Math.asinh ( x ) */ \
|
||||
V("atan", Atan, 1, ATAN) /* Math.atan ( x ) */ \
|
||||
V("atan2", Atan2, 2, INVALID) /* Math.atan2 ( y, x ) */ \
|
||||
V("atanh", Atanh, 1, INVALID) /* Math.atanh ( x ) */ \
|
||||
V("cbrt", Cbrt, 1, INVALID) /* Math.cbrt ( x ) */ \
|
||||
V("ceil", Ceil, 1, INVALID) /* Math.ceil ( x ) */ \
|
||||
V("clz32", Clz32, 1, INVALID) /* Math.clz32 ( x ) */ \
|
||||
V("cos", Cos, 1, COS) /* Math.cos ( x ) */ \
|
||||
V("cosh", Cosh, 1, INVALID) /* Math.cosh ( x ) */ \
|
||||
V("exp", Exp, 1, INVALID) /* Math.exp ( x ) */ \
|
||||
V("expm1", Expm1, 1, INVALID) /* Math.expm1 ( x ) */ \
|
||||
V("floor", Floor, 1, FLOOR) /* Math.floor ( x ) */ \
|
||||
V("fround", Fround, 1, INVALID) /* Math.fround ( x ) */ \
|
||||
V("hypot", Hypot, 2, INVALID) /* Math.hypot ( ...args ) */ \
|
||||
V("imul", Imul, 2, INVALID) /* Math.imul ( x, y ) */ \
|
||||
V("log", Log, 1, INVALID) /* Math.log ( x ) */ \
|
||||
V("log10", Log10, 1, INVALID) /* Math.log10 ( x ) */ \
|
||||
V("log1p", Log1p, 1, INVALID) /* Math.log1p ( x ) */ \
|
||||
V("log2", Log2, 1, INVALID) /* Math.log2 ( x ) */ \
|
||||
V("max", Max, 2, INVALID) /* Math.max ( ...args ) */ \
|
||||
V("min", Min, 2, INVALID) /* Math.min ( ...args ) */ \
|
||||
V("pow", Pow, 2, INVALID) /* Math.pow ( base, exponent ) */ \
|
||||
V("random", Random, 0, INVALID) /* Math.random ( ) */ \
|
||||
V("round", Round, 1, INVALID) /* Math.round ( x ) */ \
|
||||
V("sign", Sign, 1, INVALID) /* Math.sign ( x ) */ \
|
||||
V("sin", Sin, 1, SIN) /* Math.sin ( x ) */ \
|
||||
V("sinh", Sinh, 1, INVALID) /* Math.sinh ( x ) */ \
|
||||
V("sqrt", Sqrt, 1, SQRT) /* Math.sqrt ( x ) */ \
|
||||
V("tan", Tan, 1, INVALID) /* Math.tan ( x ) */ \
|
||||
V("tanh", Tanh, 1, INVALID) /* Math.tanh ( x ) */ \
|
||||
V("trunc", Trunc, 1, INVALID) /* Math.trunc ( x ) */
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsMath : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -107,6 +159,34 @@ public:
|
||||
static JSTaggedValue Tanh(EcmaRuntimeCallInfo *argv);
|
||||
// 20.2.2.35
|
||||
static JSTaggedValue Trunc(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties.
|
||||
static Span<const base::BuiltinConstantEntry> GetMathConstants()
|
||||
{
|
||||
return Span<const base::BuiltinConstantEntry>(MATH_CONSTANTS);
|
||||
}
|
||||
|
||||
static Span<const base::BuiltinFunctionEntry> GetMathFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(MATH_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_MATH_CONSTANT_ENTRY(name) \
|
||||
base::BuiltinConstantEntry::Create(#name, JSTaggedValue(BuiltinsMath::name)),
|
||||
|
||||
static inline std::array MATH_CONSTANTS = {
|
||||
BUILTIN_MATH_CONSTANTS(BUILTIN_MATH_CONSTANT_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_MATH_CONSTANT_ENTRY
|
||||
|
||||
#define BUILTIN_MATH_FUNCTION_ENTRY(name, func, length, builtinId) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsMath::func, length, kungfu::BuiltinsStubCSigns::builtinId),
|
||||
|
||||
static constexpr std::array MATH_FUNCTIONS = {
|
||||
BUILTIN_MATH_FUNCTIONS(BUILTIN_MATH_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_MATH_FUNCTION_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
#endif // ECMASCRIPT_BUILTINS_BUILTINS_MATH_H
|
||||
|
@ -19,9 +19,75 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
|
||||
// List of constants in Number, excluding '@@' internal properties.
|
||||
#define BUILTIN_NUMBER_CONSTANTS(V) \
|
||||
V(EPSILON) /* Number.EPSILON */ \
|
||||
V(MAX_SAFE_INTEGER) /* Number.MAX_SAFE_INTEGER */ \
|
||||
V(MAX_VALUE) /* Number.MAX_VALUE */ \
|
||||
V(MIN_SAFE_INTEGER) /* Number.MIN_SAFE_INTEGER */ \
|
||||
V(MIN_VALUE) /* Number.MIN_VALUE */ \
|
||||
V(NEGATIVE_INFINITY) /* Number.NEGATIVE_INFINITY */ \
|
||||
V(NaN) /* Number.NaN */ \
|
||||
V(POSITIVE_INFINITY) /* Number.POSITIVE_INFINITY */
|
||||
|
||||
// List of functions in Number.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsNumber::func refers to the native implementation of Number[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_NUMBER_NON_GLOBAL_FUNCTIONS(V) \
|
||||
V("isFinite", IsFinite, 1, INVALID) /* Number.isFinite ( number ) */ \
|
||||
V("isInteger", IsInteger, 1, INVALID) /* Number.isInteger ( number ) */ \
|
||||
V("isNaN", IsNaN, 1, INVALID) /* Number.isNaN ( number ) */ \
|
||||
V("isSafeInteger", IsSafeInteger, 1, INVALID) /* Number.isSafeInteger ( number ) */
|
||||
|
||||
// List of functions in Number that can be accessed via globalThis.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsNumber::func refers to the native implementation of Number[name].
|
||||
#define BUILTIN_NUMBER_GLOBAL_FUNCTIONS(V) \
|
||||
V("parseFloat", ParseFloat, 1, INVALID) /* Number.parseFloat ( string ) */ \
|
||||
V("parseInt", ParseInt, 2, INVALID) /* Number.parseInt ( string, radix ) */
|
||||
|
||||
#define BUILTIN_NUMBER_FUNCTIONS(V) \
|
||||
BUILTIN_NUMBER_NON_GLOBAL_FUNCTIONS(V) \
|
||||
BUILTIN_NUMBER_GLOBAL_FUNCTIONS(V)
|
||||
|
||||
// List of functions in Number.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsNumber::func refers to the native implementation of Number.prototype[name].
|
||||
#define BUILTIN_NUMBER_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* Number.prototype.toExponential ( fractionDigits ) */ \
|
||||
V("toExponential", ToExponential, 1, INVALID) \
|
||||
/* Number.prototype.toFixed ( fractionDigits ) */ \
|
||||
V("toFixed", ToFixed, 1, INVALID) \
|
||||
/* Number.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleString", ToLocaleString, 0, INVALID) \
|
||||
/* Number.prototype.toPrecision ( precision ) */ \
|
||||
V("toPrecision", ToPrecision, 1, INVALID) \
|
||||
/* Number.prototype.toString ( [ radix ] ) */ \
|
||||
V("toString", ToString, 1, INVALID) \
|
||||
/* Number.prototype.valueOf ( ) */ \
|
||||
V("valueOf", ValueOf, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsNumber : public base::BuiltinsBase {
|
||||
public:
|
||||
// 21.1.2.1 Number.EPSILON
|
||||
static constexpr double EPSILON = std::numeric_limits<double>::epsilon();
|
||||
// 21.1.2.6 Number.MAX_SAFE_INTEGER (which is 2**53 - 1 = 9007199254740991)
|
||||
static constexpr int64_t MAX_SAFE_INTEGER = (1LL << 53) - 1;
|
||||
// 21.1.2.8 Number.MIN_SAFE_INTEGER (which is -(2**53 - 1) = -9007199254740991)
|
||||
static constexpr int64_t MIN_SAFE_INTEGER = -((1LL << 53) - 1);
|
||||
// 21.1.2.7 Number.MAX_VALUE
|
||||
static constexpr double MAX_VALUE = std::numeric_limits<double>::max();
|
||||
// 21.1.2.9 Number.MIN_VALUE
|
||||
static constexpr double MIN_VALUE = std::numeric_limits<double>::denorm_min();
|
||||
// 21.1.2.14 Number.POSITIVE_INFINITY
|
||||
static constexpr double POSITIVE_INFINITY = std::numeric_limits<double>::infinity();
|
||||
// 21.1.2.11 Number.NEGATIVE_INFINITY
|
||||
static constexpr double NEGATIVE_INFINITY = -POSITIVE_INFINITY;
|
||||
// 21.1.2.10 Number.NaN
|
||||
static constexpr double NaN = NAN;
|
||||
|
||||
// 20.1.1.1
|
||||
static JSTaggedValue NumberConstructor(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
@ -52,7 +118,53 @@ public:
|
||||
// 20.1.3.7
|
||||
static JSTaggedValue ValueOf(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties.
|
||||
static Span<const base::BuiltinConstantEntry> GetNumberConstants()
|
||||
{
|
||||
return Span<const base::BuiltinConstantEntry>(NUMBER_CONSTANTS);
|
||||
}
|
||||
|
||||
// Excluding the '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetNumberNonGlobalFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(NUMBER_NON_GLOBAL_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetNumberGlobalFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(NUMBER_GLOBAL_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetNumberPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(NUMBER_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_NUMBER_CONSTANT_ENTRY(name) \
|
||||
base::BuiltinConstantEntry::Create(#name, JSTaggedValue(BuiltinsNumber::name)),
|
||||
|
||||
static inline std::array NUMBER_CONSTANTS = {
|
||||
BUILTIN_NUMBER_CONSTANTS(BUILTIN_NUMBER_CONSTANT_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_NUMBER_CONSTANT_ENTRY
|
||||
|
||||
#define BUILTIN_NUMBER_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsNumber::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array NUMBER_NON_GLOBAL_FUNCTIONS = {
|
||||
BUILTIN_NUMBER_NON_GLOBAL_FUNCTIONS(BUILTIN_NUMBER_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array NUMBER_GLOBAL_FUNCTIONS = {
|
||||
BUILTIN_NUMBER_GLOBAL_FUNCTIONS(BUILTIN_NUMBER_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array NUMBER_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_NUMBER_PROTOTYPE_FUNCTIONS(BUILTIN_NUMBER_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_NUMBER_FUNCTION_ENTRY
|
||||
|
||||
static JSTaggedNumber ThisNumberValue(JSThread *thread, EcmaRuntimeCallInfo *argv);
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
|
@ -21,6 +21,74 @@
|
||||
#include "ecmascript/js_handle.h"
|
||||
#include "ecmascript/js_hclass.h"
|
||||
|
||||
// List of functions in Object, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsObject::func refers to the native implementation of Object[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
// The following functions are not implemented yet:
|
||||
// - Object.getOwnPropertyDescriptors ( O )
|
||||
#define BUILTIN_OBJECT_FUNCTIONS(V) \
|
||||
/* Object.assign ( target, ...sources ) */ \
|
||||
V("assign", Assign, 2, INVALID) \
|
||||
/* Object.create ( O, Properties ) */ \
|
||||
V("create", Create, 2, INVALID) \
|
||||
/* Object.defineProperties ( O, Properties ) */ \
|
||||
V("defineProperties", DefineProperties, 2, INVALID) \
|
||||
/* Object.defineProperty ( O, P, Attributes ) */ \
|
||||
V("defineProperty", DefineProperty, 3, INVALID) \
|
||||
/* Object.entries ( O ) */ \
|
||||
V("entries", Entries, 1, INVALID) \
|
||||
/* Object.freeze ( O ) */ \
|
||||
V("freeze", Freeze, 1, INVALID) \
|
||||
/* Object.fromEntries ( iterable ) */ \
|
||||
V("fromEntries", FromEntries, 1, INVALID) \
|
||||
/* Object.getOwnPropertyDescriptor ( O, P ) */ \
|
||||
V("getOwnPropertyDescriptor", GetOwnPropertyDescriptor, 2, INVALID) \
|
||||
/* Object.getOwnPropertyNames ( O ) */ \
|
||||
V("getOwnPropertyNames", GetOwnPropertyNames, 1, INVALID) \
|
||||
/* Object.getOwnPropertySymbols ( O ) */ \
|
||||
V("getOwnPropertySymbols", GetOwnPropertySymbols, 1, INVALID) \
|
||||
/* Object.getPrototypeOf ( O ) */ \
|
||||
V("getPrototypeOf", GetPrototypeOf, 1, INVALID) \
|
||||
/* Object.hasOwn ( O, P ) */ \
|
||||
V("hasOwn", HasOwn, 2, INVALID) \
|
||||
/* Object.is ( value1, value2 ) */ \
|
||||
V("is", Is, 2, INVALID) \
|
||||
/* Object.isExtensible ( O ) */ \
|
||||
V("isExtensible", IsExtensible, 1, INVALID) \
|
||||
/* Object.isFrozen ( O ) */ \
|
||||
V("isFrozen", IsFrozen, 1, INVALID) \
|
||||
/* Object.isSealed ( O ) */ \
|
||||
V("isSealed", IsSealed, 1, INVALID) \
|
||||
/* Object.keys ( O ) */ \
|
||||
V("keys", Keys, 1, INVALID) \
|
||||
/* Object.preventExtensions ( O ) */ \
|
||||
V("preventExtensions", PreventExtensions, 1, INVALID) \
|
||||
/* Object.seal ( O ) */ \
|
||||
V("seal", Seal, 1, INVALID) \
|
||||
/* Object.setPrototypeOf ( O, proto ) */ \
|
||||
V("setPrototypeOf", SetPrototypeOf, 2, INVALID) \
|
||||
/* Object.values ( O ) */ \
|
||||
V("values", Values, 1, INVALID)
|
||||
|
||||
// List of functions in Object.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsObject::func refers to the native implementation of Object.prototype[name].
|
||||
#define BUILTIN_OBJECT_PROTOTYPE_FUNCTIONS(V) \
|
||||
V("createRealm", CreateRealm, 0, INVALID) \
|
||||
/* Object.prototype.hasOwnProperty ( V ) */ \
|
||||
V("hasOwnProperty", HasOwnProperty, 1, INVALID) \
|
||||
/* Object.prototype.isPrototypeOf ( V ) */ \
|
||||
V("isPrototypeOf", IsPrototypeOf, 1, INVALID) \
|
||||
/* Object.prototype.propertyIsEnumerable ( V ) */ \
|
||||
V("propertyIsEnumerable", PropertyIsEnumerable, 1, INVALID) \
|
||||
/* Object.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleString", ToLocaleString, 0, INVALID) \
|
||||
/* Object.prototype.toString ( ) */ \
|
||||
V("toString", ToString, 0, ObjectToString) \
|
||||
/* Object.prototype.valueOf ( ) */ \
|
||||
V("valueOf", ValueOf, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
enum class KeyType : uint8_t {
|
||||
STRING_TYPE = 0,
|
||||
@ -96,7 +164,29 @@ public:
|
||||
// 20.1.2.13 Object.hasOwn ( O, P )
|
||||
static JSTaggedValue HasOwn(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
static Span<const base::BuiltinFunctionEntry> GetObjectFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(OBJECT_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetObjectPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(OBJECT_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_OBJECT_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsObject::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array OBJECT_FUNCTIONS = {
|
||||
BUILTIN_OBJECT_FUNCTIONS(BUILTIN_OBJECT_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array OBJECT_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_OBJECT_PROTOTYPE_FUNCTIONS(BUILTIN_OBJECT_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_OBJECT_FUNCTION_ENTRY
|
||||
|
||||
static JSTaggedValue ObjectDefineProperties(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
|
||||
const JSHandle<JSTaggedValue> &prop);
|
||||
static JSTaggedValue GetOwnPropertyKeys(JSThread *thread, const JSHandle<JSTaggedValue> &obj, const KeyType &type);
|
||||
|
@ -23,6 +23,35 @@
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
|
||||
// List of functions in Promise, excluding the '@@' propertiex.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsPromise::func refers to the native implementation of Promise[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_PROMISE_FUNCTIONS(V) \
|
||||
/* Promise.all ( iterable ) */ \
|
||||
V("all", All, 1, INVALID) \
|
||||
/* Promise.allSettled ( iterable ) */ \
|
||||
V("allSettled", AllSettled, 1, INVALID) \
|
||||
/* Promise.any ( iterable ) */ \
|
||||
V("any", Any, 1, INVALID) \
|
||||
/* Promise.race ( iterable ) */ \
|
||||
V("race", Race, 1, INVALID) \
|
||||
/* Promise.reject ( r ) */ \
|
||||
V("reject", Reject, 1, INVALID) \
|
||||
/* Promise.resolve ( x ) */ \
|
||||
V("resolve", Resolve, 1, INVALID)
|
||||
|
||||
// List of functions in Promise.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsPromise::func refers to the native implementation of Promise.prototype[name].
|
||||
#define BUILTIN_PROMISE_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* Promise.prototype.catch ( onRejected ) */ \
|
||||
V("catch", Catch, 1, INVALID) \
|
||||
/* Promise.prototype.finally ( onFinally ) */ \
|
||||
V("finally", Finally, 1, INVALID) \
|
||||
/* Promise.prototype.then ( onFulfilled, onRejected ) */ \
|
||||
V("then", Then, 2, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsPromise : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -56,7 +85,30 @@ public:
|
||||
|
||||
static JSTaggedValue GetPromiseResolve(JSThread *thread, JSHandle<JSTaggedValue> promiseConstructor);
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetPromiseFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(PROMISE_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetPromisePrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(PROMISE_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_PROMISE_FUNCTION_ENTRY(name, method, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsPromise::method, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array PROMISE_FUNCTIONS = {
|
||||
BUILTIN_PROMISE_FUNCTIONS(BUILTIN_PROMISE_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array PROMISE_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_PROMISE_PROTOTYPE_FUNCTIONS(BUILTIN_PROMISE_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_PROMISE_FUNCTION_ENTRY
|
||||
|
||||
static JSTaggedValue PerformPromiseAll(JSThread *thread,
|
||||
const JSHandle<PromiseIteratorRecord> &itRecord,
|
||||
const JSHandle<JSTaggedValue> &ctor,
|
||||
|
@ -20,6 +20,38 @@
|
||||
#include "ecmascript/js_function.h"
|
||||
#include "ecmascript/js_array.h"
|
||||
|
||||
// List of functions in Reflect, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsRefject::func refers to the native implementation of Reflect[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_REFLECT_FUNCTIONS(V) \
|
||||
/* Reflect.apply ( target, thisArgument, argumentsList ) */ \
|
||||
V("apply", ReflectApply, 3, INVALID) \
|
||||
/* Reflect.construct ( target, argumentsList [ , newTarget ] ) */ \
|
||||
V("construct", ReflectConstruct, 2, INVALID) \
|
||||
/* Reflect.defineProperty ( target, propertyKey, attributes ) */ \
|
||||
V("defineProperty", ReflectDefineProperty, 3, INVALID) \
|
||||
/* Reflect.deleteProperty ( target, propertyKey ) */ \
|
||||
V("deleteProperty", ReflectDeleteProperty, 2, INVALID) \
|
||||
/* Reflect.get ( target, propertyKey [ , receiver ] ) */ \
|
||||
V("get", ReflectGet, 2, INVALID) \
|
||||
/* Reflect.getOwnPropertyDescriptor ( target, propertyKey ) */ \
|
||||
V("getOwnPropertyDescriptor", ReflectGetOwnPropertyDescriptor, 2, INVALID) \
|
||||
/* Reflect.getPrototypeOf ( target ) */ \
|
||||
V("getPrototypeOf", ReflectGetPrototypeOf, 1, INVALID) \
|
||||
/* Reflect.has ( target, propertyKey ) */ \
|
||||
V("has", ReflectHas, 2, INVALID) \
|
||||
/* Reflect.isExtensible ( target ) */ \
|
||||
V("isExtensible", ReflectIsExtensible, 1, INVALID) \
|
||||
/* Reflect.ownKeys ( target ) */ \
|
||||
V("ownKeys", ReflectOwnKeys, 1, INVALID) \
|
||||
/* Reflect.preventExtensions ( target ) */ \
|
||||
V("preventExtensions", ReflectPreventExtensions, 1, INVALID) \
|
||||
/* Reflect.set ( target, propertyKey, V [ , receiver ] ) */ \
|
||||
V("set", ReflectSet, 3, INVALID) \
|
||||
/* Reflect.setPrototypeOf ( target, proto ) */ \
|
||||
V("setPrototypeOf", ReflectSetPrototypeOf, 2, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsReflect : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -61,6 +93,21 @@ public:
|
||||
|
||||
// ecma 26.1.13
|
||||
static JSTaggedValue ReflectSetPrototypeOf(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetReflectFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(REFLECT_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTINS_REFLECT_FUNCTION_ENTRY(name, method, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsReflect::method, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array REFLECT_FUNCTIONS = {
|
||||
BUILTIN_REFLECT_FUNCTIONS(BUILTINS_REFLECT_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTINS_REFLECT_FUNCTION_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
#endif // ECMASCRIPT_BUILTINS_BUILTINS_REFLECT_H
|
||||
|
@ -19,6 +19,28 @@
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
#include "ecmascript/ecma_runtime_call_info.h"
|
||||
|
||||
// List of functions in Set, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsSet::func refers to the native implementation of Set.prototype[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
// The following functions are not listed:
|
||||
// - Set.prototype.keys ( ), which is strictly equal to Set.prototype.values
|
||||
#define BUILTIN_SET_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* Set.prototype.add ( value ) */ \
|
||||
V("add", Add, 1, SetAdd) \
|
||||
/* Set.prototype.clear ( ) */ \
|
||||
V("clear", Clear, 0, INVALID) \
|
||||
/* Set.prototype.delete ( value ) */ \
|
||||
V("delete", Delete, 1, SetDelete) \
|
||||
/* Set.prototype.entries ( ) */ \
|
||||
V("entries", Entries, 0, INVALID) \
|
||||
/* Set.prototype.forEach ( callbackfn [ , thisArg ] ) */ \
|
||||
V("forEach", ForEach, 1, SetForEach) \
|
||||
/* Set.prototype.has ( value ) */ \
|
||||
V("has", Has, 1, INVALID) \
|
||||
/* Set.prototype.values ( ) */ \
|
||||
V("values", Values, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsSet : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -42,6 +64,22 @@ public:
|
||||
static JSTaggedValue GetSize(EcmaRuntimeCallInfo *argv);
|
||||
// 23.2.3.10
|
||||
static JSTaggedValue Values(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetSetPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(SET_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_SET_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsSet::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array SET_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_SET_PROTOTYPE_FUNCTIONS(BUILTIN_SET_FUNCTION_ENTRY)
|
||||
};
|
||||
|
||||
#undef BUILTIN_SET_FUNCTION_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
#endif // ECMASCRIPT_BUILTINS_BUILTINS_SET_H
|
||||
|
@ -20,6 +20,101 @@
|
||||
#include "ecmascript/ecma_runtime_call_info.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
|
||||
// List of functions in String, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsString::func refers to the native implementation of String[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_STRING_FUNCTIONS(V) \
|
||||
/* String.fromCharCode ( ...codeUnits ) */ \
|
||||
V("fromCharCode", FromCharCode, 1, StringFromCharCode) \
|
||||
/* String.fromCodePoint ( ...codePoints ) */ \
|
||||
V("fromCodePoint", FromCodePoint, 1, INVALID) \
|
||||
/* String.raw ( template, ...substitutions ) */ \
|
||||
V("raw", Raw, 1, INVALID)
|
||||
|
||||
// List of functions in String.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsString::func refers to the native implementation of String.prototype[name].
|
||||
// The following functions in String.prototype are not implemented yet:
|
||||
// - String.prototype.isWellFormed ( )
|
||||
// - String.prototype.toWellFormed ( )
|
||||
#define BUILTIN_STRING_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* String.prototype.at ( index ) */ \
|
||||
V("at", At, 1, INVALID) \
|
||||
/* String.prototype.charAt ( pos ) */ \
|
||||
V("charAt", CharAt, 1, StringCharAt) \
|
||||
/* String.prototype.charCodeAt ( pos ) */ \
|
||||
V("charCodeAt", CharCodeAt, 1, StringCharCodeAt) \
|
||||
/* String.prototype.codePointAt ( pos ) */ \
|
||||
V("codePointAt", CodePointAt, 1, INVALID) \
|
||||
/* String.prototype.concat ( ...args ) */ \
|
||||
V("concat", Concat, 1, INVALID) \
|
||||
/* String.prototype.endsWith ( searchString [ , endPosition ] ) */ \
|
||||
V("endsWith", EndsWith, 1, INVALID) \
|
||||
/* String.prototype.includes ( searchString [ , position ] ) */ \
|
||||
V("includes", Includes, 1, INVALID) \
|
||||
/* String.prototype.indexOf ( searchString [ , position ] ) */ \
|
||||
V("indexOf", IndexOf, 1, StringIndexOf) \
|
||||
/* String.prototype.lastIndexOf ( searchString [ , position ] ) */ \
|
||||
V("lastIndexOf", LastIndexOf, 1, INVALID) \
|
||||
/* String.prototype.localeCompare ( that [ , reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("localeCompare", LocaleCompare, 1, LocaleCompare) \
|
||||
/* String.prototype.match ( regexp ) */ \
|
||||
V("match", Match, 1, INVALID) \
|
||||
/* String.prototype.matchAll ( regexp ) */ \
|
||||
V("matchAll", MatchAll, 1, INVALID) \
|
||||
/* String.prototype.normalize ( [ form ] ) */ \
|
||||
V("normalize", Normalize, 0, INVALID) \
|
||||
/* String.prototype.padEnd ( maxLength [ , fillString ] ) */ \
|
||||
V("padEnd", PadEnd, 1, INVALID) \
|
||||
/* String.prototype.padStart ( maxLength [ , fillString ] ) */ \
|
||||
V("padStart", PadStart, 1, INVALID) \
|
||||
/* String.prototype.repeat ( count ) */ \
|
||||
V("repeat", Repeat, 1, INVALID) \
|
||||
/* String.prototype.replace ( searchValue, replaceValue ) */ \
|
||||
V("replace", Replace, 2, INVALID) \
|
||||
/* String.prototype.replaceAll ( searchValue, replaceValue ) */ \
|
||||
V("replaceAll", ReplaceAll, 2, INVALID) \
|
||||
/* String.prototype.search ( regexp ) */ \
|
||||
V("search", Search, 1, INVALID) \
|
||||
/* String.prototype.slice ( start, end ) */ \
|
||||
V("slice", Slice, 2, INVALID) \
|
||||
/* String.prototype.split ( separator, limit ) */ \
|
||||
V("split", Split, 2, INVALID) \
|
||||
/* String.prototype.startsWith ( searchString [ , position ] ) */ \
|
||||
V("startsWith", StartsWith, 1, INVALID) \
|
||||
/* In Annex B.2.2: Additional Properties of the String.prototype Object */ \
|
||||
/* String.prototype.substr ( start, length ) */ \
|
||||
V("substr", SubStr, 2, INVALID) \
|
||||
/* String.prototype.substring ( start, end ) */ \
|
||||
V("substring", Substring, 2, StringSubstring) \
|
||||
/* String.prototype.toLocaleLowerCase ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleLowerCase", ToLocaleLowerCase, 0, INVALID) \
|
||||
/* String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleUpperCase", ToLocaleUpperCase, 0, INVALID) \
|
||||
/* String.prototype.toLowerCase ( ) */ \
|
||||
V("toLowerCase", ToLowerCase, 0, INVALID) \
|
||||
/* String.prototype.toString ( ) */ \
|
||||
V("toString", ToString, 0, INVALID) \
|
||||
/* String.prototype.toUpperCase ( ) */ \
|
||||
V("toUpperCase", ToUpperCase, 0, INVALID) \
|
||||
/* String.prototype.trim ( ) */ \
|
||||
V("trim", Trim, 0, INVALID) \
|
||||
/* String.prototype.trimEnd ( ) */ \
|
||||
V("trimEnd", TrimEnd, 0, INVALID) \
|
||||
/* In Annex B.2.2: Additional Properties of the String.prototype Object */ \
|
||||
/* Equivalent to trimStart. For compatibility only. */ \
|
||||
/* String.prototype.trimLeft ( ) */ \
|
||||
V("trimLeft", TrimLeft, 0, INVALID) \
|
||||
/* In Annex B.2.2: Additional Properties of the String.prototype Object */ \
|
||||
/* Equivalent to trimEnd. For compatibility only. */ \
|
||||
/* String.prototype.trimEnd ( ) */ \
|
||||
V("trimRight", TrimRight, 0, INVALID) \
|
||||
/* String.prototype.trimStart ( ) */ \
|
||||
V("trimStart", TrimStart, 0, INVALID) \
|
||||
/* String.prototype.valueOf ( ) */ \
|
||||
V("valueOf", ValueOf, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
constexpr int32_t ENCODE_MAX_UTF16 = 0X10FFFF;
|
||||
constexpr uint16_t ENCODE_LEAD_LOW = 0xD800;
|
||||
@ -127,7 +222,30 @@ public:
|
||||
|
||||
static JSTaggedValue GetLength(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetStringFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(STRING_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetStringPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(STRING_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_STRING_FUNCTION_ENTRY(name, method, length, builtinId) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsString::method, length, kungfu::BuiltinsStubCSigns::builtinId),
|
||||
|
||||
static constexpr std::array STRING_FUNCTIONS = {
|
||||
BUILTIN_STRING_FUNCTIONS(BUILTIN_STRING_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array STRING_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_STRING_PROTOTYPE_FUNCTIONS(BUILTIN_STRING_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_STRING_FUNCTION_ENTRY
|
||||
|
||||
static JSTaggedValue Pad(EcmaRuntimeCallInfo *argv, bool isStart);
|
||||
static int32_t ConvertDoubleToInt(double d);
|
||||
// 21.1.3.17.1
|
||||
|
@ -20,6 +20,44 @@
|
||||
#include "ecmascript/ecma_runtime_call_info.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
|
||||
#define BUILTIN_WELL_KNOWN_SYMBOLS(V) \
|
||||
V(hasInstance, HasInstance) \
|
||||
V(isConcatSpreadable, IsConcatSpreadable) \
|
||||
V(toStringTag, ToStringTag)
|
||||
|
||||
#define BUILTIN_PUBLIC_SYMBOLS(V) \
|
||||
V(asyncIterator, AsyncIterator) \
|
||||
V(attach, Attach) \
|
||||
V(detach, Detach) \
|
||||
V(iterator, Iterator) \
|
||||
V(match, Match) \
|
||||
V(matchAll, MatchAll) \
|
||||
V(replace, Replace) \
|
||||
V(search, Search) \
|
||||
V(species, Species) \
|
||||
V(split, Split) \
|
||||
V(toPrimitive, ToPrimitive) \
|
||||
V(unscopables, Unscopables)
|
||||
|
||||
#define BUILTIN_ALL_SYMBOLS(V) \
|
||||
BUILTIN_WELL_KNOWN_SYMBOLS(V) \
|
||||
BUILTIN_PUBLIC_SYMBOLS(V)
|
||||
|
||||
// List of functions in Symbol, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsSymbol::func refers to the native implementation of Symbol[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_SYMBOL_FUNCTIONS(V) \
|
||||
V("for", For, 1, INVALID) \
|
||||
V("keyFor", KeyFor, 1, INVALID)
|
||||
|
||||
// List of get accessors in Symbol.prototype, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsSymbol::func refers to the native implementation of Symbol.prototype[name].
|
||||
#define BUILTIN_SYMBOL_PROTOTYPE_FUNCTIONS(V) \
|
||||
V("toString", ToString, 0, INVALID) \
|
||||
V("valueOf", ValueOf, 0, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsSymbol : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -45,6 +83,31 @@ public:
|
||||
static JSTaggedValue ToPrimitive(EcmaRuntimeCallInfo *argv);
|
||||
|
||||
static JSTaggedValue SymbolDescriptiveString(JSThread *thread, JSTaggedValue sym);
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetSymbolFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(SYMBOL_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetSymbolPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(SYMBOL_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_SYMBOL_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsSymbol::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array SYMBOL_FUNCTIONS = {
|
||||
BUILTIN_SYMBOL_FUNCTIONS(BUILTIN_SYMBOL_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array SYMBOL_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_SYMBOL_PROTOTYPE_FUNCTIONS(BUILTIN_SYMBOL_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_TYPED_ARRAY_FUNCTION_ENTRY
|
||||
#undef BUILTIN_TYPED_ARRAY_ACCESSOR_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
#endif // ECMASCRIPT_BUILTINS_BUILTINS_SYMBOL_H
|
||||
|
@ -18,6 +18,107 @@
|
||||
|
||||
#include "ecmascript/base/builtins_base.h"
|
||||
|
||||
// All types of %TypedArray%.
|
||||
// V(Type, TYPE, bytesPerElement) where JSType::JS_##TYPE is the type index.
|
||||
#define BUILTIN_TYPED_ARRAY_TYPES(V) \
|
||||
V(Int8Array, INT8_ARRAY, 1) \
|
||||
V(Uint8Array, UINT8_ARRAY, 1) \
|
||||
V(Uint8ClampedArray, UINT8_CLAMPED_ARRAY, 1) \
|
||||
V(Int16Array, INT16_ARRAY, 2) \
|
||||
V(Uint16Array, UINT16_ARRAY, 2) \
|
||||
V(Int32Array, INT32_ARRAY, 4) \
|
||||
V(Uint32Array, UINT32_ARRAY, 4) \
|
||||
V(Float32Array, FLOAT32_ARRAY, 4) \
|
||||
V(Float64Array, FLOAT64_ARRAY, 8) \
|
||||
V(BigInt64Array, BIGINT64_ARRAY, 8) \
|
||||
V(BigUint64Array, BIGUINT64_ARRAY, 8)
|
||||
|
||||
// List of functions in %TypedArray%, excluding the '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsTypedArray::func refers to the native implementation of %TypedArray%[name].
|
||||
// kungfu::BuiltinsStubCSigns::stubIndex refers to the builtin stub index, or INVALID if no stub available.
|
||||
#define BUILTIN_TYPED_ARRAY_FUNCTIONS(V) \
|
||||
/* %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) */ \
|
||||
V("from", From, 1, INVALID) \
|
||||
/* %TypedArray%.of ( ...items ) */ \
|
||||
V("of", Of, 0, INVALID)
|
||||
|
||||
// List of get accessors in %TypedArray%.prototype, excluding the '@@' properties.
|
||||
// V(name, func, stubIndex)
|
||||
// where BuiltinsTypedArray::func refers to the native implementation.
|
||||
#define BUILTIN_TYPED_ARRAY_PROTOTYPE_GETTERS(V) \
|
||||
V("buffer", GetBuffer, INVALID) /* get %TypedArray%.prototype.buffer */ \
|
||||
V("byteLength", GetByteLength, INVALID) /* get %TypedArray%.prototype.byteLength */ \
|
||||
V("byteOffset", GetByteOffset, INVALID) /* get %TypedArray%.prototype.byteOffset */ \
|
||||
V("length", GetLength, INVALID) /* get %TypedArray%.prototype.length */
|
||||
|
||||
// List of functions in %TypedArray%.prototype, excluding the constructor and '@@' properties.
|
||||
// V(name, func, length, stubIndex)
|
||||
// where BuiltinsTypedArray::func refers to the native implementation of %TypedArray%.prototype[name].
|
||||
// The following functions are not included:
|
||||
// - %TypedArray%.prototype.toString ( ), which is strictly equal to Array.prototype.toString
|
||||
#define BUILTIN_TYPED_ARRAY_PROTOTYPE_FUNCTIONS(V) \
|
||||
/* %TypedArray%.prototype.at ( index ) */ \
|
||||
V("at", At, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.copyWithin ( target, start [ , end ] ) */ \
|
||||
V("copyWithin", CopyWithin, 2, INVALID) \
|
||||
/* %TypedArray%.prototype.entries ( ) */ \
|
||||
V("entries", Entries, 0, INVALID) \
|
||||
/* %TypedArray%.prototype.every ( callbackfn [ , thisArg ] ) */ \
|
||||
V("every", Every, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.fill ( value [ , start [ , end ] ] ) */ \
|
||||
V("fill", Fill, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) */ \
|
||||
V("filter", Filter, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.find ( predicate [ , thisArg ] ) */ \
|
||||
V("find", Find, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) */ \
|
||||
V("findIndex", FindIndex, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.findLast ( predicate [ , thisArg ] ) */ \
|
||||
V("findLast", FindLast, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) */ \
|
||||
V("findLastIndex", FindLastIndex, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) */ \
|
||||
V("forEach", ForEach, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) */ \
|
||||
V("includes", Includes, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) */ \
|
||||
V("indexOf", IndexOf, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.join ( separator ) */ \
|
||||
V("join", Join, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.keys ( ) */ \
|
||||
V("keys", Keys, 0, INVALID) \
|
||||
/* %TypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) */ \
|
||||
V("lastIndexOf", LastIndexOf, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.map ( callbackfn [ , thisArg ] ) */ \
|
||||
V("map", Map, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) */ \
|
||||
V("reduce", Reduce, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) */ \
|
||||
V("reduceRight", ReduceRight, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.reverse ( ) */ \
|
||||
V("reverse", Reverse, 0, INVALID) \
|
||||
/* %TypedArray%.prototype.set ( source [ , offset ] ) */ \
|
||||
V("set", Set, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.slice ( start, end ) */ \
|
||||
V("slice", Slice, 2, INVALID) \
|
||||
/* %TypedArray%.prototype.some ( callbackfn [ , thisArg ] ) */ \
|
||||
V("some", Some, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.sort ( comparefn ) */ \
|
||||
V("sort", Sort, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.subarray ( begin, end ) */ \
|
||||
V("subarray", Subarray, 2, INVALID) \
|
||||
/* %TypedArray%.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) */ \
|
||||
V("toLocaleString", ToLocaleString, 0, INVALID) \
|
||||
/* %TypedArray%.prototype.toReversed ( ) */ \
|
||||
V("toReversed", ToReversed, 0, INVALID) \
|
||||
/* %TypedArray%.prototype.toSorted ( comparefn ) */ \
|
||||
V("toSorted", ToSorted, 1, INVALID) \
|
||||
/* %TypedArray%.prototype.values ( ) */ \
|
||||
V("values", Values, 0, INVALID) \
|
||||
/* %TypedArray%.prototype.with ( index, value ) */ \
|
||||
V("with", With, 2, INVALID)
|
||||
|
||||
namespace panda::ecmascript::builtins {
|
||||
class BuiltinsTypedArray : public base::BuiltinsBase {
|
||||
public:
|
||||
@ -120,6 +221,43 @@ public:
|
||||
// 23.2.3.36
|
||||
static JSTaggedValue With(EcmaRuntimeCallInfo *argv);
|
||||
static const uint32_t MAX_ARRAY_INDEX = std::numeric_limits<uint32_t>::max();
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetTypedArrayFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(TYPED_ARRAY_FUNCTIONS);
|
||||
}
|
||||
|
||||
// Excluding the '@@' internal properties
|
||||
static Span<const base::BuiltinFunctionEntry> GetTypedArrayPrototypeAccessors()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(TYPED_ARRAY_PROTOTYPE_ACCESSORS);
|
||||
}
|
||||
|
||||
// Excluding the constructor and '@@' internal properties.
|
||||
static Span<const base::BuiltinFunctionEntry> GetTypedArrayPrototypeFunctions()
|
||||
{
|
||||
return Span<const base::BuiltinFunctionEntry>(TYPED_ARRAY_PROTOTYPE_FUNCTIONS);
|
||||
}
|
||||
|
||||
private:
|
||||
#define BUILTIN_TYPED_ARRAY_FUNCTION_ENTRY(name, func, length, id) \
|
||||
base::BuiltinFunctionEntry::Create(name, BuiltinsTypedArray::func, length, kungfu::BuiltinsStubCSigns::id),
|
||||
#define BUILTIN_TYPED_ARRAY_ACCESSOR_ENTRY(name, func, id) \
|
||||
base::BuiltinFunctionEntry::Create<base::BuiltinFunctionEntry::IsAccessorBit>( \
|
||||
name, BuiltinsTypedArray::func, 0, kungfu::BuiltinsStubCSigns::id),
|
||||
|
||||
static constexpr std::array TYPED_ARRAY_FUNCTIONS = {
|
||||
BUILTIN_TYPED_ARRAY_FUNCTIONS(BUILTIN_TYPED_ARRAY_FUNCTION_ENTRY)
|
||||
};
|
||||
static constexpr std::array TYPED_ARRAY_PROTOTYPE_ACCESSORS = {
|
||||
BUILTIN_TYPED_ARRAY_PROTOTYPE_GETTERS(BUILTIN_TYPED_ARRAY_ACCESSOR_ENTRY)
|
||||
};
|
||||
static constexpr std::array TYPED_ARRAY_PROTOTYPE_FUNCTIONS = {
|
||||
BUILTIN_TYPED_ARRAY_PROTOTYPE_FUNCTIONS(BUILTIN_TYPED_ARRAY_FUNCTION_ENTRY)
|
||||
};
|
||||
#undef BUILTIN_TYPED_ARRAY_FUNCTION_ENTRY
|
||||
#undef BUILTIN_TYPED_ARRAY_ACCESSOR_ENTRY
|
||||
};
|
||||
} // namespace panda::ecmascript::builtins
|
||||
|
||||
|
@ -507,7 +507,7 @@ GateRef Circuit::GetConstantGate(MachineType machineType, uint64_t value,
|
||||
{
|
||||
auto search = constantCache_.find({machineType, value, type});
|
||||
if (search != constantCache_.end()) {
|
||||
return constantCache_.at({machineType, value, type});
|
||||
return search->second;
|
||||
}
|
||||
auto gate = NewGate(metaBuilder_.Constant(value), machineType, type);
|
||||
constantCache_[{machineType, value, type}] = gate;
|
||||
|
@ -484,9 +484,10 @@ void JSHClass::TransitToElementsKind(const JSThread *thread, const JSHandle<JSAr
|
||||
if (newKind == current) {
|
||||
return;
|
||||
}
|
||||
auto arrayHClassIndexMap = thread->GetArrayHClassIndexMap();
|
||||
if (arrayHClassIndexMap.find(newKind) != arrayHClassIndexMap.end()) {
|
||||
auto index = static_cast<size_t>(thread->GetArrayHClassIndexMap().at(newKind));
|
||||
const auto &arrayHClassIndexMap = thread->GetArrayHClassIndexMap();
|
||||
auto newKindIter = arrayHClassIndexMap.find(newKind);
|
||||
if (newKindIter != arrayHClassIndexMap.end()) {
|
||||
auto index = static_cast<size_t>(newKindIter->second);
|
||||
auto hclassVal = thread->GlobalConstants()->GetGlobalConstantObject(index);
|
||||
JSHClass *hclass = JSHClass::Cast(hclassVal.GetTaggedObject());
|
||||
array->SetClass(hclass);
|
||||
@ -509,9 +510,10 @@ bool JSHClass::TransitToElementsKind(
|
||||
if (newKind == current) {
|
||||
return false;
|
||||
}
|
||||
auto arrayHClassIndexMap = thread->GetArrayHClassIndexMap();
|
||||
if (arrayHClassIndexMap.find(newKind) != arrayHClassIndexMap.end()) {
|
||||
auto index = static_cast<size_t>(thread->GetArrayHClassIndexMap().at(newKind));
|
||||
const auto &arrayHClassIndexMap = thread->GetArrayHClassIndexMap();
|
||||
auto newKindIter = arrayHClassIndexMap.find(newKind);
|
||||
if (newKindIter != arrayHClassIndexMap.end()) {
|
||||
auto index = static_cast<size_t>(newKindIter->second);
|
||||
auto hclassVal = thread->GlobalConstants()->GetGlobalConstantObject(index);
|
||||
JSHClass *hclass = JSHClass::Cast(hclassVal.GetTaggedObject());
|
||||
object->SetClass(hclass);
|
||||
|
@ -1978,25 +1978,25 @@ JSHandle<JSSymbol> ObjectFactory::NewSymbolWithTable(const JSHandle<JSTaggedValu
|
||||
return obj;
|
||||
}
|
||||
|
||||
JSHandle<JSSymbol> ObjectFactory::NewPrivateNameSymbolWithChar(const char *description)
|
||||
JSHandle<JSSymbol> ObjectFactory::NewPrivateNameSymbolWithChar(std::string_view description)
|
||||
{
|
||||
JSHandle<EcmaString> string = NewFromUtf8(description);
|
||||
return NewPrivateNameSymbol(JSHandle<JSTaggedValue>(string));
|
||||
}
|
||||
|
||||
JSHandle<JSSymbol> ObjectFactory::NewWellKnownSymbolWithChar(const char *description)
|
||||
JSHandle<JSSymbol> ObjectFactory::NewWellKnownSymbolWithChar(std::string_view description)
|
||||
{
|
||||
JSHandle<EcmaString> string = NewFromUtf8(description);
|
||||
return NewWellKnownSymbol(JSHandle<JSTaggedValue>(string));
|
||||
}
|
||||
|
||||
JSHandle<JSSymbol> ObjectFactory::NewPublicSymbolWithChar(const char *description)
|
||||
JSHandle<JSSymbol> ObjectFactory::NewPublicSymbolWithChar(std::string_view description)
|
||||
{
|
||||
JSHandle<EcmaString> string = NewFromUtf8(description);
|
||||
return NewPublicSymbol(JSHandle<JSTaggedValue>(string));
|
||||
}
|
||||
|
||||
JSHandle<JSSymbol> ObjectFactory::NewSymbolWithTableWithChar(const char *description)
|
||||
JSHandle<JSSymbol> ObjectFactory::NewSymbolWithTableWithChar(std::string_view description)
|
||||
{
|
||||
JSHandle<EcmaString> string = NewFromUtf8(description);
|
||||
return NewSymbolWithTable(JSHandle<JSTaggedValue>(string));
|
||||
@ -3451,31 +3451,31 @@ JSHandle<TSNamespaceType> ObjectFactory::NewTSNamespaceType()
|
||||
return namespaceType;
|
||||
}
|
||||
// ----------------------------------- new string ----------------------------------------
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromASCII(const CString &data)
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromASCII(std::string_view data)
|
||||
{
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.c_str());
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.data());
|
||||
ASSERT(EcmaStringAccessor::CanBeCompressed(utf8Data, data.length()));
|
||||
return GetStringFromStringTable(utf8Data, data.length(), true);
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromASCIINonMovable(const CString &data)
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromASCIINonMovable(std::string_view data)
|
||||
{
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.c_str());
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.data());
|
||||
ASSERT(EcmaStringAccessor::CanBeCompressed(utf8Data, data.length()));
|
||||
return GetStringFromStringTableNonMovable(utf8Data, data.length());
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromUtf8(const CString &data)
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromUtf8(std::string_view data)
|
||||
{
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.c_str());
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.data());
|
||||
bool canBeCompress = EcmaStringAccessor::CanBeCompressed(utf8Data, data.length());
|
||||
return GetStringFromStringTable(utf8Data, data.length(), canBeCompress);
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromUtf16(const CS16tring &data)
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromUtf16(std::u16string_view data)
|
||||
{
|
||||
uint32_t length = data.length();
|
||||
auto utf16Data = reinterpret_cast<const uint16_t *>(data.c_str());
|
||||
auto utf16Data = reinterpret_cast<const uint16_t *>(data.data());
|
||||
bool canBeCompress = EcmaStringAccessor::CanBeCompressed(utf16Data, length);
|
||||
return GetStringFromStringTable(utf16Data, length, canBeCompress);
|
||||
}
|
||||
|
@ -287,13 +287,13 @@ public:
|
||||
|
||||
JSHandle<JSSymbol> NewSymbolWithTable(const JSHandle<JSTaggedValue> &name);
|
||||
|
||||
JSHandle<JSSymbol> NewPrivateNameSymbolWithChar(const char *description);
|
||||
JSHandle<JSSymbol> NewPrivateNameSymbolWithChar(std::string_view description);
|
||||
|
||||
JSHandle<JSSymbol> NewWellKnownSymbolWithChar(const char *description);
|
||||
JSHandle<JSSymbol> NewWellKnownSymbolWithChar(std::string_view description);
|
||||
|
||||
JSHandle<JSSymbol> NewPublicSymbolWithChar(const char *description);
|
||||
JSHandle<JSSymbol> NewPublicSymbolWithChar(std::string_view description);
|
||||
|
||||
JSHandle<JSSymbol> NewSymbolWithTableWithChar(const char *description);
|
||||
JSHandle<JSSymbol> NewSymbolWithTableWithChar(std::string_view description);
|
||||
|
||||
JSHandle<AccessorData> NewAccessorData();
|
||||
JSHandle<AccessorData> NewInternalAccessor(void *setter, void *getter);
|
||||
@ -518,9 +518,9 @@ public:
|
||||
JSHandle<TSNamespaceType> NewTSNamespaceType();
|
||||
|
||||
// ----------------------------------- new string ----------------------------------------
|
||||
JSHandle<EcmaString> NewFromASCII(const CString &data);
|
||||
JSHandle<EcmaString> NewFromUtf8(const CString &data);
|
||||
JSHandle<EcmaString> NewFromUtf16(const CS16tring &data);
|
||||
JSHandle<EcmaString> NewFromASCII(std::string_view data);
|
||||
JSHandle<EcmaString> NewFromUtf8(std::string_view data);
|
||||
JSHandle<EcmaString> NewFromUtf16(std::u16string_view data);
|
||||
|
||||
JSHandle<EcmaString> NewFromStdString(const std::string &data);
|
||||
|
||||
@ -673,7 +673,7 @@ private:
|
||||
JSHandle<JSObject> NewNonMovableJSObject(const JSHandle<JSHClass> &jshclass);
|
||||
|
||||
// used to create nonmovable utf8 string at global constants
|
||||
JSHandle<EcmaString> NewFromASCIINonMovable(const CString &data);
|
||||
JSHandle<EcmaString> NewFromASCIINonMovable(std::string_view data);
|
||||
|
||||
// used for creating Function
|
||||
JSHandle<JSFunction> NewJSFunction(const JSHandle<GlobalEnv> &env, const JSHandle<JSHClass> &hclass);
|
||||
|
@ -16,7 +16,9 @@
|
||||
#ifndef ECMASCRIPT_OBJECT_FAST_OPERATOR_H
|
||||
#define ECMASCRIPT_OBJECT_FAST_OPERATOR_H
|
||||
|
||||
#include "ecmascript/js_hclass.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/property_attributes.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
class ObjectFastOperator final {
|
||||
|
@ -456,8 +456,9 @@ void RuntimeStubs::DumpToStreamWithHint(std::ostream &out, std::string_view hint
|
||||
// Begin line
|
||||
out << dumpDelimiterLine << " Begin dump: " << hint << ' ' << dumpDelimiterLine << std::endl;
|
||||
// Dumps raw data
|
||||
out << "(Raw value = 0x" << std::setw(16) << std::hex << std::setfill('0') << value.GetRawData() << ") ";
|
||||
out << std::setfill(' '); // Recovers fill character
|
||||
out << "(Raw value = 0x" << std::setw(base::INT64_HEX_DIGITS) << std::hex
|
||||
<< std::setfill('0') << value.GetRawData() << ") ";
|
||||
out << std::dec << std::setfill(' '); // Recovers integer radix & fill character
|
||||
// Dumps tagged value
|
||||
value.Dump(out);
|
||||
// End line
|
||||
|
@ -18,7 +18,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "ecmascript/ecma_vm.h"
|
||||
#include "ecmascript/js_handle.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
#include "ecmascript/tagged_array.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
|
Loading…
Reference in New Issue
Block a user