mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Improve TLS valriable r/w on ELF shared-libary
since calling __tls_get_addr performace is too bad, we should r/w TLS variables with special offset users can turn on this feature with ESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS flag Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
e575d34387
commit
2c0c041c9a
68 changed files with 385 additions and 284 deletions
16
.github/workflows/es-actions.yml
vendored
16
.github/workflows/es-actions.yml
vendored
|
|
@ -121,13 +121,13 @@ jobs:
|
|||
sudo apt-get install -y ninja-build gcc-multilib g++-multilib libicu-dev
|
||||
- name: Build x86
|
||||
env:
|
||||
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
run: |
|
||||
CC=clang CXX=clang++ cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/clang/x86 $BUILD_OPTIONS
|
||||
ninja -Cout/clang/x86
|
||||
- name: Build x64
|
||||
env:
|
||||
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS: -DESCARGOT_MODE=debug -DESCARGOT_WASM=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
run: |
|
||||
CC=clang CXX=clang++ cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/clang/x64 $BUILD_OPTIONS
|
||||
ninja -Cout/clang/x64
|
||||
|
|
@ -305,7 +305,7 @@ jobs:
|
|||
dpkg -X libicu-dev_70.1-2ubuntu1_i386.deb $GITHUB_WORKSPACE/icu32
|
||||
- name: Build x86
|
||||
env:
|
||||
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_THREADING=ON -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_THREADING=ON -DESCARGOT_LIBICU_SUPPORT_WITH_DLOPEN=OFF -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
run: |
|
||||
export CXXFLAGS="-I$GITHUB_WORKSPACE/icu32/usr/include"
|
||||
export LDFLAGS="-L$GITHUB_WORKSPACE/icu32/usr/lib/i386-linux-gnu -Wl,-rpath=$GITHUB_WORKSPACE/icu32/usr/lib/i386-linux-gnu"
|
||||
|
|
@ -341,7 +341,7 @@ jobs:
|
|||
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 1
|
||||
- name: Build x64
|
||||
env:
|
||||
BUILD_OPTIONS: -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS: -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
run: |
|
||||
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/release/x64 $BUILD_OPTIONS ${{ matrix.build_opt }}
|
||||
ninja -Cout/release/x64
|
||||
|
|
@ -373,8 +373,8 @@ jobs:
|
|||
sudo apt-get install -y libicu-dev:i386 # install i386 ICU
|
||||
- name: Build x86/x64
|
||||
env:
|
||||
BUILD_OPTIONS_X86: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS_X64: -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS_X86: -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS_X64: -DESCARGOT_MODE=debug -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
run: |
|
||||
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/debug/x86 $BUILD_OPTIONS_X86
|
||||
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H. -Bout/debug/x64 $BUILD_OPTIONS_X64
|
||||
|
|
@ -394,7 +394,7 @@ jobs:
|
|||
submodules: true
|
||||
- name: Build
|
||||
env:
|
||||
BUILD_OPTIONS: -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
BUILD_OPTIONS: -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
run: |
|
||||
LDFLAGS=" -L/usr/icu32/lib/ -Wl,-rpath=/usr/icu32/lib/" PKG_CONFIG_PATH="/usr/icu32/lib/pkgconfig/" cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bbuild/out_linux -DESCARGOT_ARCH=x86 -DESCARGOT_MODE=debug -DESCARGOT_TCO_DEBUG=ON $BUILD_OPTIONS
|
||||
LDFLAGS=" -L/usr/icu32/lib/ -Wl,-rpath=/usr/icu32/lib/" PKG_CONFIG_PATH="/usr/icu32/lib/pkgconfig/" cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bbuild/out_linux_release -DESCARGOT_ARCH=x86 $BUILD_OPTIONS
|
||||
|
|
@ -421,7 +421,7 @@ jobs:
|
|||
submodules: true
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bout -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=arm32 -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -H./ -Bout -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=arm32 -DESCARGOT_MODE=release -DESCARGOT_THREADING=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -DESCARGOT_TEST=ON -DESCARGOT_OUTPUT=shell -GNinja
|
||||
cmake --build ./out/
|
||||
- name: Test
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -162,6 +162,10 @@ IF (ESCARGOT_TEMPORAL)
|
|||
SET (ESCARGOT_DEFINITIONS ${ESCARGOT_DEFINITIONS} -DENABLE_TEMPORAL)
|
||||
ENDIF()
|
||||
|
||||
IF (ESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
SET (ESCARGOT_DEFINITIONS ${ESCARGOT_DEFINITIONS} -DENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
ENDIF()
|
||||
|
||||
IF (ESCARGOT_TEST)
|
||||
SET (ESCARGOT_DEFINITIONS ${ESCARGOT_DEFINITIONS} -DESCARGOT_ENABLE_TEST)
|
||||
IF (ESCARGOT_CODE_CACHE)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ ENDIF()
|
|||
IF (ESCARGOT_THREADING)
|
||||
SET (GCUTIL_ENABLE_THREADING ON)
|
||||
ENDIF()
|
||||
IF (ESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
SET (GCUTIL_ENABLE_TLS_ACCESS_BY_ADDRESS ON)
|
||||
ENDIF()
|
||||
|
||||
SET (GCUTIL_MODE ${ESCARGOT_MODE})
|
||||
|
||||
|
|
|
|||
|
|
@ -260,11 +260,11 @@ CXXFLAGS+=' -Wno-shadow '
|
|||
%if "%{?enable_test}" == "1"
|
||||
cmake CMakeLists.txt -H./ -Bbuild/out_tizen_%{rpm} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} -DTIZEN_MAJOR_VERSION='%{tizen_version_major}' \
|
||||
-DESCARGOT_ARCH='%{tizen_arch}' -DESCARGOT_WASM='%{enable_wasm}' -DESCARGOT_DEBUGGER='%{enable_debugger}' \
|
||||
-DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_MODE=release -DESCARGOT_HOST=tizen -DESCARGOT_OUTPUT=shared_lib -DESCARGOT_TEST=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -G Ninja
|
||||
-DESCARGOT_THREADING=ON -DESCARGOT_TCO=ON -DESCARGOT_MODE=release -DESCARGOT_HOST=tizen -DESCARGOT_OUTPUT=shared_lib -DESCARGOT_TEST=ON -DESCARGOT_TEMPORAL=ON -DESCARGOT_TCO=ON -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -G Ninja
|
||||
%else
|
||||
cmake CMakeLists.txt -H./ -Bbuild/out_tizen_%{rpm} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} -DTIZEN_MAJOR_VERSION='%{tizen_version_major}' \
|
||||
-DESCARGOT_ARCH='%{tizen_arch}' -DESCARGOT_WASM='%{enable_wasm}' -DESCARGOT_DEBUGGER='%{enable_debugger}' \
|
||||
-DESCARGOT_THREADING=ON -DESCARGOT_MODE=release -DESCARGOT_HOST=tizen -DESCARGOT_OUTPUT=shared_lib -G Ninja
|
||||
-DESCARGOT_THREADING=ON -DESCARGOT_MODE=release -DESCARGOT_HOST=tizen -DESCARGOT_OUTPUT=shared_lib -DESCARGOT_ENABLE_TLS_ACCESS_BY_ADDRESS=ON -G Ninja
|
||||
%endif
|
||||
|
||||
cmake --build build/out_tizen_%{rpm}
|
||||
|
|
|
|||
|
|
@ -694,7 +694,7 @@ StringRef* StringRef::createReloadableString(VMInstanceRef* instance, bool is8Bi
|
|||
|
||||
StringRef* StringRef::emptyString()
|
||||
{
|
||||
return toRef(String::emptyString);
|
||||
return toRef(String::emptyString());
|
||||
}
|
||||
|
||||
char16_t StringRef::charAt(size_t idx)
|
||||
|
|
@ -987,10 +987,10 @@ bool BigIntRef::isNegative()
|
|||
}
|
||||
|
||||
Evaluator::StackTraceData::StackTraceData()
|
||||
: srcName(toRef(String::emptyString))
|
||||
, sourceCode(toRef(String::emptyString))
|
||||
: srcName(toRef(String::emptyString()))
|
||||
, sourceCode(toRef(String::emptyString()))
|
||||
, loc(SIZE_MAX, SIZE_MAX, SIZE_MAX)
|
||||
, functionName(toRef(String::emptyString))
|
||||
, functionName(toRef(String::emptyString()))
|
||||
, callee(nullptr)
|
||||
, isFunction(false)
|
||||
, isConstructor(false)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ static Object* arraySpeciesCreate(ExecutionState& state, Object* originalArray,
|
|||
}
|
||||
// If IsConstructor(C) is false, throw a TypeError exception.
|
||||
if (!C.isConstructor()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().Array.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_ThisNotConstructor);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().Array.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_ThisNotConstructor);
|
||||
}
|
||||
// Return Construct(C, <<length>>).
|
||||
Value argv[1] = { Value(length) };
|
||||
|
|
@ -367,7 +367,7 @@ static Value builtinArrayJoin(ExecutionState& state, Value thisValue, size_t arg
|
|||
}
|
||||
|
||||
if (!state.context()->toStringRecursionPreventer()->canInvokeToString(thisBinded)) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
ToStringRecursionPreventerItemAutoHolder holder(state, thisBinded);
|
||||
|
||||
|
|
@ -1367,7 +1367,7 @@ static Value builtinArrayToLocaleString(ExecutionState& state, Value thisValue,
|
|||
Object* array = thisValue.toObject(state);
|
||||
|
||||
if (!state.context()->toStringRecursionPreventer()->canInvokeToString(array)) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
ToStringRecursionPreventerItemAutoHolder holder(state, array);
|
||||
|
||||
|
|
@ -1378,7 +1378,7 @@ static Value builtinArrayToLocaleString(ExecutionState& state, Value thisValue,
|
|||
String* separator = state.context()->staticStrings().asciiTable[(size_t)','].string();
|
||||
|
||||
// Let R be the empty String.
|
||||
String* R = String::emptyString;
|
||||
String* R = String::emptyString();
|
||||
|
||||
// Let k be 0.
|
||||
uint64_t k = 0;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static Value builtinArrayBufferConstructor(ExecutionState& state, Value thisValu
|
|||
|
||||
uint64_t byteLength = argv[0].toIndex(state);
|
||||
if (UNLIKELY(byteLength == Value::InvalidIndexValue)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ static Value builtinArrayBufferConstructor(ExecutionState& state, Value thisValu
|
|||
if (!maxLengthValue.isUndefined()) {
|
||||
maxByteLength = maxLengthValue.toIndex(state);
|
||||
if (UNLIKELY((maxByteLength.value() == Value::InvalidIndexValue) || (byteLength > maxByteLength.value()))) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Escargot {
|
|||
static Value builtinAsyncFunction(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
size_t argumentVectorCount = argc > 1 ? argc - 1 : 0;
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString);
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString());
|
||||
auto functionSource = FunctionObject::createDynamicFunctionScript(state, state.context()->staticStrings().anonymous, argumentVectorCount, argv, sourceValue, false, false, true, false);
|
||||
|
||||
// Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto).
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Escargot {
|
|||
static Value builtinAsyncGeneratorFunction(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
size_t argumentVectorCount = argc > 1 ? argc - 1 : 0;
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString);
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString());
|
||||
auto functionSource = FunctionObject::createDynamicFunctionScript(state, state.context()->staticStrings().anonymous, argumentVectorCount, argv, sourceValue, false, true, true, false);
|
||||
|
||||
// Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto).
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ static Value builtinDataViewConstructor(ExecutionState& state, Value thisValue,
|
|||
return Value();
|
||||
}
|
||||
if (!(argv[0].isObject() && argv[0].asPointerValue()->isArrayBuffer())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_ThisNotArrayBufferObject);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_ThisNotArrayBufferObject);
|
||||
}
|
||||
|
||||
ArrayBuffer* buffer = argv[0].asObject()->asArrayBuffer();
|
||||
|
|
@ -54,16 +54,16 @@ static Value builtinDataViewConstructor(ExecutionState& state, Value thisValue,
|
|||
Value& val = argv[1];
|
||||
byteOffset = val.toIndex(state);
|
||||
if (byteOffset == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
}
|
||||
if (buffer->isDetachedBuffer()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, "%s: ArrayBuffer is detached buffer");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), "%s: ArrayBuffer is detached buffer");
|
||||
}
|
||||
double bufferByteLength = buffer->byteLength();
|
||||
|
||||
if (byteOffset > bufferByteLength) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
double byteLength = bufferByteLength - byteOffset;
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ static Value builtinDataViewConstructor(ExecutionState& state, Value thisValue,
|
|||
if (!val.isUndefined()) {
|
||||
byteLength = val.toIndex(state);
|
||||
if (byteOffset + byteLength > bufferByteLength || byteLength == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ static Value builtinDataViewConstructor(ExecutionState& state, Value thisValue,
|
|||
obj->setBuffer(buffer, byteOffset, byteLength, 0, argc < 3);
|
||||
|
||||
if (obj->buffer()->isDetachedBuffer()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_DetachedBuffer);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_DetachedBuffer);
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ static Value builtinErrorConstructor(ExecutionState& state, Value thisValue, siz
|
|||
});
|
||||
|
||||
#if defined(ENABLE_EXTENDED_API)
|
||||
ErrorObject* obj = new ErrorObject(state, proto, String::emptyString, true, state.context()->vmInstance()->isErrorCreationCallbackRegistered());
|
||||
ErrorObject* obj = new ErrorObject(state, proto, String::emptyString(), true, state.context()->vmInstance()->isErrorCreationCallbackRegistered());
|
||||
#else
|
||||
ErrorObject* obj = new ErrorObject(state, proto, String::emptyString);
|
||||
ErrorObject* obj = new ErrorObject(state, proto, String::emptyString());
|
||||
#endif
|
||||
|
||||
Value message = argv[0];
|
||||
|
|
@ -81,7 +81,7 @@ static Value builtinErrorConstructor(ExecutionState& state, Value thisValue, siz
|
|||
Object* proto = Object::getPrototypeFromConstructor(state, newTarget.value(), [](ExecutionState& state, Context* constructorRealm) -> Object* { \
|
||||
return constructorRealm->globalObject()->lowerCaseErrorName##ErrorPrototype(); \
|
||||
}); \
|
||||
ErrorObject* obj = new errorName##ErrorObject(state, proto, String::emptyString, true, state.context()->vmInstance()->isErrorCreationCallbackRegistered()); \
|
||||
ErrorObject* obj = new errorName##ErrorObject(state, proto, String::emptyString(), true, state.context()->vmInstance()->isErrorCreationCallbackRegistered()); \
|
||||
Value message = argv[0]; \
|
||||
if (!message.isUndefined()) { \
|
||||
obj->defineOwnPropertyThrowsException(state, state.context()->staticStrings().message, \
|
||||
|
|
@ -101,7 +101,7 @@ static Value builtinErrorConstructor(ExecutionState& state, Value thisValue, siz
|
|||
Object* proto = Object::getPrototypeFromConstructor(state, newTarget.value(), [](ExecutionState& state, Context* constructorRealm) -> Object* { \
|
||||
return constructorRealm->globalObject()->lowerCaseErrorName##ErrorPrototype(); \
|
||||
}); \
|
||||
ErrorObject* obj = new errorName##ErrorObject(state, proto, String::emptyString); \
|
||||
ErrorObject* obj = new errorName##ErrorObject(state, proto, String::emptyString()); \
|
||||
Value message = argv[0]; \
|
||||
if (!message.isUndefined()) { \
|
||||
obj->defineOwnPropertyThrowsException(state, state.context()->staticStrings().message, \
|
||||
|
|
@ -132,9 +132,9 @@ static Value builtinAggregateErrorConstructor(ExecutionState& state, Value thisV
|
|||
});
|
||||
|
||||
#if defined(ENABLE_EXTENDED_API)
|
||||
ErrorObject* O = new AggregateErrorObject(state, proto, String::emptyString, true, state.context()->vmInstance()->isErrorCreationCallbackRegistered());
|
||||
ErrorObject* O = new AggregateErrorObject(state, proto, String::emptyString(), true, state.context()->vmInstance()->isErrorCreationCallbackRegistered());
|
||||
#else
|
||||
ErrorObject* O = new AggregateErrorObject(state, proto, String::emptyString);
|
||||
ErrorObject* O = new AggregateErrorObject(state, proto, String::emptyString());
|
||||
#endif
|
||||
|
||||
Value message = argv[1];
|
||||
|
|
@ -175,7 +175,7 @@ static Value builtinErrorToString(ExecutionState& state, Value thisValue, size_t
|
|||
Object* o = thisValue.toObject(state);
|
||||
|
||||
if (!state.context()->toStringRecursionPreventer()->canInvokeToString(o)) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
ToStringRecursionPreventerItemAutoHolder holder(state, o);
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ static Value builtinErrorToString(ExecutionState& state, Value thisValue, size_t
|
|||
Value message = o->get(state, state.context()->staticStrings().message).value(state, o);
|
||||
String* messageStr;
|
||||
if (message.isUndefined()) {
|
||||
messageStr = String::emptyString;
|
||||
messageStr = String::emptyString();
|
||||
} else {
|
||||
messageStr = message.toString(state);
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ void GlobalObject::installError(ExecutionState& state)
|
|||
|
||||
m_errorPrototype->directDefineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().constructor), ObjectPropertyDescriptor(m_error, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
|
||||
m_errorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().message, ObjectPropertyDescriptor(String::emptyString, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
m_errorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().message, ObjectPropertyDescriptor(String::emptyString(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
m_errorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().name, ObjectPropertyDescriptor(state.context()->staticStrings().Error.string(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
auto errorToStringFn = new NativeFunctionObject(state, NativeFunctionInfo(state.context()->staticStrings().toString, builtinErrorToString, 0, NativeFunctionInfo::Strict));
|
||||
m_errorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().toString, ObjectPropertyDescriptor(errorToStringFn, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectPropertyDescriptor::ConfigurablePresent)));
|
||||
|
|
@ -266,7 +266,7 @@ void GlobalObject::installError(ExecutionState& state)
|
|||
m_throwTypeError->defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().length),
|
||||
ObjectPropertyDescriptor(Value(0), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::NonConfigurablePresent)));
|
||||
m_throwTypeError->defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().name),
|
||||
ObjectPropertyDescriptor(String::emptyString, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::NonConfigurablePresent)));
|
||||
ObjectPropertyDescriptor(String::emptyString(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::NonWritablePresent | ObjectPropertyDescriptor::NonEnumerablePresent | ObjectPropertyDescriptor::NonConfigurablePresent)));
|
||||
m_throwTypeError->preventExtensions(state);
|
||||
|
||||
m_throwerGetterSetterData = new JSGetterSetter(m_throwTypeError, m_throwTypeError);
|
||||
|
|
@ -277,7 +277,7 @@ void GlobalObject::installError(ExecutionState& state)
|
|||
m_##errorname##ErrorPrototype = new PrototypeObject(state, m_errorPrototype); \
|
||||
m_##errorname##ErrorPrototype->setGlobalIntrinsicObject(state, true); \
|
||||
m_##errorname##ErrorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().constructor, ObjectPropertyDescriptor(m_##errorname##Error, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##ErrorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().message, ObjectPropertyDescriptor(String::emptyString, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##ErrorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().message, ObjectPropertyDescriptor(String::emptyString(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##ErrorPrototype->directDefineOwnProperty(state, state.context()->staticStrings().name, ObjectPropertyDescriptor(state.context()->staticStrings().bname##Error.string(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##Error->setFunctionPrototype(state, m_##errorname##ErrorPrototype); \
|
||||
redefineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().bname##Error), \
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static Value builtinFunctionConstructor(ExecutionState& state, Value thisValue,
|
|||
}
|
||||
|
||||
size_t argumentVectorCount = argc > 1 ? argc - 1 : 0;
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString);
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString());
|
||||
auto functionSource = FunctionObject::createDynamicFunctionScript(state, state.context()->staticStrings().anonymous, argumentVectorCount, argv, sourceValue, false, false, false, false);
|
||||
|
||||
// Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto).
|
||||
|
|
@ -179,7 +179,7 @@ static Value builtinFunctionBind(ExecutionState& state, Value thisValue, size_t
|
|||
Value targetName = target->get(state, ObjectPropertyName(state.context()->staticStrings().name)).value(state, target);
|
||||
// If Type(targetName) is not String, let targetName be the empty string.
|
||||
if (!targetName.isString()) {
|
||||
targetName = String::emptyString;
|
||||
targetName = String::emptyString();
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Escargot {
|
|||
static Value builtinGeneratorFunction(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
size_t argumentVectorCount = argc > 1 ? argc - 1 : 0;
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString);
|
||||
Value sourceValue = argc >= 1 ? argv[argc - 1] : Value(String::emptyString());
|
||||
auto functionSource = FunctionObject::createDynamicFunctionScript(state, state.context()->staticStrings().anonymous, argumentVectorCount, argv, sourceValue, false, true, false, false);
|
||||
|
||||
// Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto).
|
||||
|
|
|
|||
|
|
@ -641,7 +641,7 @@ static Value builtinDefineGetter(ExecutionState& state, Value thisValue, size_t
|
|||
Object* O = thisValue.toObject(state);
|
||||
// If IsCallable(getter) is false, throw a TypeError exception.
|
||||
if (!argv[1].isCallable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::emptyString, true, state.context()->staticStrings().__defineGetter__.string(), ErrorObject::Messages::GlobalObject_CallbackNotCallable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::emptyString(), true, state.context()->staticStrings().__defineGetter__.string(), ErrorObject::Messages::GlobalObject_CallbackNotCallable);
|
||||
}
|
||||
// Let desc be PropertyDescriptor{[[Get]]: getter, [[Enumerable]]: true, [[Configurable]]: true}.
|
||||
ObjectPropertyDescriptor desc(JSGetterSetter(argv[1].asObject(), Value(Value::EmptyValue)), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::EnumerablePresent | ObjectPropertyDescriptor::ConfigurablePresent));
|
||||
|
|
@ -667,7 +667,7 @@ static Value builtinDefineSetter(ExecutionState& state, Value thisValue, size_t
|
|||
Object* O = thisValue.toObject(state);
|
||||
// If IsCallable(getter) is false, throw a TypeError exception.
|
||||
if (!argv[1].isCallable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::emptyString, true, state.context()->staticStrings().__defineSetter__.string(), ErrorObject::Messages::GlobalObject_CallbackNotCallable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::emptyString(), true, state.context()->staticStrings().__defineSetter__.string(), ErrorObject::Messages::GlobalObject_CallbackNotCallable);
|
||||
}
|
||||
// Let desc be PropertyDescriptor{[[Get]]: getter, [[Enumerable]]: true, [[Configurable]]: true}.
|
||||
ObjectPropertyDescriptor desc(JSGetterSetter(Value(Value::EmptyValue), argv[1].asObject()), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::EnumerablePresent | ObjectPropertyDescriptor::ConfigurablePresent));
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ static Value builtinPromiseConstructor(ExecutionState& state, Value thisValue, s
|
|||
{
|
||||
auto strings = &state.context()->staticStrings();
|
||||
if (!newTarget.hasValue()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Promise.string(), false, String::emptyString, "%s: Promise constructor should be called with new Promise()");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Promise.string(), false, String::emptyString(), "%s: Promise constructor should be called with new Promise()");
|
||||
return Value();
|
||||
}
|
||||
|
||||
Value executor = argv[0];
|
||||
if (!executor.isCallable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Promise.string(), false, String::emptyString, "%s: Promise executor is not a function object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Promise.string(), false, String::emptyString(), "%s: Promise executor is not a function object");
|
||||
}
|
||||
|
||||
// Let promise be ? OrdinaryCreateFromConstructor(NewTarget, "%PromisePrototype%", « [[PromiseState]], [[PromiseResult]], [[PromiseFulfillReactions]], [[PromiseRejectReactions]], [[PromiseIsHandled]] »).
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static Value builtinProxyConstructor(ExecutionState& state, Value thisValue, siz
|
|||
auto strings = &state.context()->staticStrings();
|
||||
|
||||
if (!newTarget.hasValue()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: calling a builtin Proxy constructor without new is forbidden");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: calling a builtin Proxy constructor without new is forbidden");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ static Value builtinReflectApply(ExecutionState& state, Value thisValue, size_t
|
|||
|
||||
// 1. If IsCallable(target) is false, throw a TypeError exception.
|
||||
if (!target.isObject() || !target.asObject()->isCallable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: calling a not-callable target in apply function is forbidden");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: calling a not-callable target in apply function is forbidden");
|
||||
}
|
||||
|
||||
// 2. Let args be CreateListFromArrayLike(argumentsList).
|
||||
|
|
@ -59,13 +59,13 @@ static Value builtinReflectConstruct(ExecutionState& state, Value thisValue, siz
|
|||
|
||||
// 1. If IsConstructor(target) is false, throw a TypeError exception.
|
||||
if (!target.isConstructor()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.construct should has a construct method");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.construct should has a construct method");
|
||||
}
|
||||
|
||||
// 2. If newTarget is not present, let newTarget be target.
|
||||
// 3. Else, if IsConstructor(newTarget) is false, throw a TypeError exception.
|
||||
if (!newTargetArg.isConstructor()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The new target of Reflect.construct should be a constructor");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The new target of Reflect.construct should be a constructor");
|
||||
}
|
||||
|
||||
// 4. Let args be CreateListFromArrayLike(argumentsList).
|
||||
|
|
@ -82,7 +82,7 @@ static Value builtinReflectDefineProperty(ExecutionState& state, Value thisValue
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.defineProperty should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.defineProperty should be an Object");
|
||||
}
|
||||
|
||||
// 2. Let key be ToPropertyKey(propertyKey).
|
||||
|
|
@ -90,7 +90,7 @@ static Value builtinReflectDefineProperty(ExecutionState& state, Value thisValue
|
|||
|
||||
// 3. Let desc be ToPropertyDescriptor(attributes).
|
||||
if (!argv[2].isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The attributes of Reflect.defineProperty should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The attributes of Reflect.defineProperty should be an Object");
|
||||
}
|
||||
ObjectPropertyDescriptor desc(state, argv[2].asObject());
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ static Value builtinReflectDeleteProperty(ExecutionState& state, Value thisValue
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.deleteProperty should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.deleteProperty should be an Object");
|
||||
}
|
||||
|
||||
// 2. Let key be ToPropertyKey(propertyKey).
|
||||
|
|
@ -124,7 +124,7 @@ static Value builtinReflectGet(ExecutionState& state, Value thisValue, size_t ar
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.get should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.get should be an Object");
|
||||
}
|
||||
|
||||
// 2. Let key be ToPropertyKey(propertyKey).
|
||||
|
|
@ -146,7 +146,7 @@ static Value builtinReflectGetOwnPropertyDescriptor(ExecutionState& state, Value
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.getOwnPropertyDescriptor should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.getOwnPropertyDescriptor should be an Object");
|
||||
}
|
||||
|
||||
// 2. Let key be ToPropertyKey(propertyKey).
|
||||
|
|
@ -167,7 +167,7 @@ static Value builtinReflectGetPrototypeOf(ExecutionState& state, Value thisValue
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.getPrototypeOf should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.getPrototypeOf should be an Object");
|
||||
}
|
||||
|
||||
// 2. Return target.[[GetPrototypeOf]]().
|
||||
|
|
@ -182,7 +182,7 @@ static Value builtinReflectHas(ExecutionState& state, Value thisValue, size_t ar
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.has should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.has should be an Object");
|
||||
}
|
||||
|
||||
// 2. Let key be ToPropertyKey(propertyKey).
|
||||
|
|
@ -200,7 +200,7 @@ static Value builtinReflectIsExtensible(ExecutionState& state, Value thisValue,
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.isExtensible should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.isExtensible should be an Object");
|
||||
}
|
||||
|
||||
// 2. Return target.[[IsExtensible]]().
|
||||
|
|
@ -215,7 +215,7 @@ static Value builtinReflectPreventExtensions(ExecutionState& state, Value thisVa
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.preventExtension should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.preventExtension should be an Object");
|
||||
}
|
||||
|
||||
// 2. Return target.[[PreventExtensions]]().
|
||||
|
|
@ -230,7 +230,7 @@ static Value builtinReflectOwnKeys(ExecutionState& state, Value thisValue, size_
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.preventExtension should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.preventExtension should be an Object");
|
||||
}
|
||||
// 2. Let keys be target.[[OwnPropertyKeys]]().
|
||||
// 3. ReturnIfAbrupt(keys).
|
||||
|
|
@ -248,7 +248,7 @@ static Value builtinReflectSet(ExecutionState& state, Value thisValue, size_t ar
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.set should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.set should be an Object");
|
||||
}
|
||||
|
||||
// 2. Let key be ToPropertyKey(propertyKey).
|
||||
|
|
@ -271,12 +271,12 @@ static Value builtinReflectSetPrototypeOf(ExecutionState& state, Value thisValue
|
|||
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The target of Reflect.setPrototypeOf should be an Object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The target of Reflect.setPrototypeOf should be an Object");
|
||||
}
|
||||
|
||||
// 2. If Type(proto) is not Object and proto is not null, throw a TypeError exception
|
||||
if (!proto.isObject() && !proto.isNull()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString, "%s: The proto of Reflect.setPrototypeOf should be an Object or Null");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Reflect.string(), false, String::emptyString(), "%s: The proto of Reflect.setPrototypeOf should be an Object or Null");
|
||||
}
|
||||
|
||||
// 3. Return target.[[SetPrototypeOf]](proto).
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ static Value builtinRegExpConstructor(ExecutionState& state, Value thisValue, si
|
|||
{
|
||||
Value pattern = argv[0];
|
||||
Value flags = argv[1];
|
||||
String* source = pattern.isUndefined() ? String::emptyString : pattern.toString(state);
|
||||
String* option = flags.isUndefined() ? String::emptyString : flags.toString(state);
|
||||
String* source = pattern.isUndefined() ? String::emptyString() : pattern.toString(state);
|
||||
String* option = flags.isUndefined() ? String::emptyString() : flags.toString(state);
|
||||
|
||||
// Let patternIsRegExp be IsRegExp(pattern).
|
||||
bool patternIsRegExp = argv[0].isObject() && argv[0].asObject()->isRegExp(state);
|
||||
|
|
@ -61,10 +61,10 @@ static Value builtinRegExpConstructor(ExecutionState& state, Value thisValue, si
|
|||
option = flags.isUndefined() ? RegExpObject::computeRegExpOptionString(state, patternRegExp) : flags.toString(state);
|
||||
} else if (patternIsRegExp) {
|
||||
Value P = pattern.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().source)).value(state, pattern);
|
||||
source = P.isUndefined() ? String::emptyString : P.toString(state);
|
||||
source = P.isUndefined() ? String::emptyString() : P.toString(state);
|
||||
if (flags.isUndefined()) {
|
||||
Value F = pattern.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().flags)).value(state, pattern);
|
||||
option = F.isUndefined() ? String::emptyString : F.toString(state);
|
||||
option = F.isUndefined() ? String::emptyString() : F.toString(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,8 +239,8 @@ static Value builtinRegExpCompile(ExecutionState& state, Value thisValue, size_t
|
|||
}
|
||||
|
||||
RegExpObject* retVal = thisValue.asPointerValue()->asObject()->asRegExpObject();
|
||||
String* patternStr = argv[0].isUndefined() ? String::emptyString : argv[0].toString(state);
|
||||
String* flagsStr = argv[1].isUndefined() ? String::emptyString : argv[1].toString(state);
|
||||
String* patternStr = argv[0].isUndefined() ? String::emptyString() : argv[0].toString(state);
|
||||
String* flagsStr = argv[1].isUndefined() ? String::emptyString() : argv[1].toString(state);
|
||||
retVal->init(state, patternStr, flagsStr);
|
||||
return retVal;
|
||||
}
|
||||
|
|
@ -422,7 +422,7 @@ static Value builtinRegExpReplace(ExecutionState& state, Value thisValue, size_t
|
|||
size_t lengthStr = str->length();
|
||||
bool functionalReplace = replaceValue.isCallable();
|
||||
bool fullUnicode = false;
|
||||
String* replacement = String::emptyString;
|
||||
String* replacement = String::emptyString();
|
||||
size_t nextSourcePosition = 0;
|
||||
StringBuilder builder;
|
||||
|
||||
|
|
@ -494,7 +494,7 @@ static Value builtinRegExpReplace(ExecutionState& state, Value thisValue, size_t
|
|||
if (!capN.isUndefined()) {
|
||||
captures.push_back(capN.toString(state));
|
||||
} else {
|
||||
captures.push_back(String::emptyString);
|
||||
captures.push_back(String::emptyString());
|
||||
}
|
||||
if (functionalReplace) {
|
||||
replacerArgs[n] = capN;
|
||||
|
|
@ -748,7 +748,7 @@ static Value builtinRegExpInputSetter(ExecutionState& state, Value thisValue, si
|
|||
if (!status.isValid()) { \
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ErrorObject::Messages::String_InvalidStringLength); \
|
||||
} \
|
||||
return (status.dollarCount < number) ? String::emptyString : new StringView(status.dollars[number - 1]); \
|
||||
return (status.dollarCount < number) ? String::emptyString() : new StringView(status.dollars[number - 1]); \
|
||||
}
|
||||
|
||||
REGEXP_LEGACY_FEATURES(DEFINE_LEGACY_FEATURE_GETTER);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ static Value builtinSharedArrayBufferConstructor(ExecutionState& state, Value th
|
|||
|
||||
uint64_t byteLength = argv[0].toIndex(state);
|
||||
if (byteLength == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
}
|
||||
|
||||
Optional<uint64_t> maxByteLength;
|
||||
|
|
@ -48,7 +48,7 @@ static Value builtinSharedArrayBufferConstructor(ExecutionState& state, Value th
|
|||
if (!maxLengthValue.isUndefined()) {
|
||||
maxByteLength = maxLengthValue.toIndex(state);
|
||||
if (UNLIKELY((maxByteLength.value() == Value::InvalidIndexValue) || (byteLength > maxByteLength.value()))) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Escargot {
|
|||
|
||||
static Value builtinStringConstructor(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
|
||||
{
|
||||
String* s = String::emptyString;
|
||||
String* s = String::emptyString();
|
||||
if (argc > 0) {
|
||||
Value value = argv[0];
|
||||
if (!newTarget.hasValue() && value.isSymbol()) {
|
||||
|
|
@ -203,7 +203,7 @@ static Value builtinStringMatch(ExecutionState& state, Value thisValue, size_t a
|
|||
}
|
||||
|
||||
String* S = thisValue.toString(state);
|
||||
RegExpObject* rx = new RegExpObject(state, regexp.isUndefined() ? String::emptyString : regexp.toString(state), String::emptyString);
|
||||
RegExpObject* rx = new RegExpObject(state, regexp.isUndefined() ? String::emptyString() : regexp.toString(state), String::emptyString());
|
||||
Value func = rx->get(state, ObjectPropertyName(state.context()->vmInstance()->globalSymbols().match)).value(state, rx);
|
||||
Value args[1] = { Value(S) };
|
||||
return Object::call(state, func, rx, 1, args);
|
||||
|
|
@ -232,7 +232,7 @@ static Value builtinStringMatchAll(ExecutionState& state, Value thisValue, size_
|
|||
String* S = thisValue.toString(state);
|
||||
StringBuilder builder;
|
||||
builder.appendChar('g');
|
||||
RegExpObject* rx = new RegExpObject(state, regexp.isUndefined() ? String::emptyString : regexp.toString(state), builder.finalize());
|
||||
RegExpObject* rx = new RegExpObject(state, regexp.isUndefined() ? String::emptyString() : regexp.toString(state), builder.finalize());
|
||||
Value func = rx->get(state, ObjectPropertyName(state.context()->vmInstance()->globalSymbols().matchAll)).value(state, rx);
|
||||
Value args[1] = { Value(S) };
|
||||
return Object::call(state, func, rx, 1, args);
|
||||
|
|
@ -328,7 +328,7 @@ static Value builtinStringRepeat(ExecutionState& state, Value thisValue, size_t
|
|||
}
|
||||
|
||||
if (newStringLength == 0) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
repeatCount = static_cast<int32_t>(count);
|
||||
|
|
@ -545,7 +545,7 @@ static Value builtinStringReplace(ExecutionState& state, Value thisValue, size_t
|
|||
if (pos == SIZE_MAX) {
|
||||
return Value(string);
|
||||
}
|
||||
String* replStr = String::emptyString;
|
||||
String* replStr = String::emptyString();
|
||||
if (functionalReplace) {
|
||||
Value parameters[3] = { Value(matched), Value(pos), Value(string) };
|
||||
Value replValue = Object::call(state, replaceValue, Value(), 3, parameters);
|
||||
|
|
@ -612,7 +612,7 @@ static Value builtinStringReplaceAll(ExecutionState& state, Value thisValue, siz
|
|||
size_t endOfLastMatch = 0;
|
||||
|
||||
StringBuilder builder;
|
||||
String* replacement = String::emptyString;
|
||||
String* replacement = String::emptyString();
|
||||
// For each element p of matchPositions, do
|
||||
for (size_t i = 0; i < matchPositions.size(); i++) {
|
||||
size_t p = matchPositions[i];
|
||||
|
|
@ -651,7 +651,7 @@ static Value builtinStringSearch(ExecutionState& state, Value thisValue, size_t
|
|||
}
|
||||
|
||||
String* string = thisValue.toString(state);
|
||||
RegExpObject* rx = new RegExpObject(state, regexp.isUndefined() ? String::emptyString : regexp.toString(state), String::emptyString);
|
||||
RegExpObject* rx = new RegExpObject(state, regexp.isUndefined() ? String::emptyString() : regexp.toString(state), String::emptyString());
|
||||
Value func = rx->get(state, ObjectPropertyName(state.context()->vmInstance()->globalSymbols().search)).value(state, rx);
|
||||
Value args[1] = { Value(string) };
|
||||
return Object::call(state, func, rx, 1, args);
|
||||
|
|
@ -859,7 +859,7 @@ static Value builtinStringCharAt(ExecutionState& state, Value thisValue, size_t
|
|||
char16_t c = str->charAt(position);
|
||||
return state.context()->staticStrings().charCodeToString(c);
|
||||
} else {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -989,7 +989,7 @@ static Value builtinStringToLowerCase(ExecutionState& state, Value thisValue, si
|
|||
}
|
||||
|
||||
#if defined(ENABLE_ICU)
|
||||
return stringToLocaleConvertCase(state, str, String::emptyString, false);
|
||||
return stringToLocaleConvertCase(state, str, String::emptyString(), false);
|
||||
#else
|
||||
size_t len = str->length();
|
||||
UTF16StringData newStr;
|
||||
|
|
@ -1074,7 +1074,7 @@ static Value builtinStringToUpperCase(ExecutionState& state, Value thisValue, si
|
|||
}
|
||||
|
||||
#if defined(ENABLE_ICU)
|
||||
return stringToLocaleConvertCase(state, str, String::emptyString, true);
|
||||
return stringToLocaleConvertCase(state, str, String::emptyString(), true);
|
||||
#else
|
||||
size_t len = str->length();
|
||||
UTF16StringData newStr;
|
||||
|
|
@ -1283,7 +1283,7 @@ static Value builtinStringRaw(ExecutionState& state, Value thisValue, size_t arg
|
|||
double literalSegments = raw->length(state);
|
||||
// If literalSegments ≤ 0, return the empty string.
|
||||
if (literalSegments <= 0) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
// Let stringElements be a new empty List.
|
||||
StringBuilder stringElements;
|
||||
|
|
@ -1309,7 +1309,7 @@ static Value builtinStringRaw(ExecutionState& state, Value thisValue, size_t arg
|
|||
next = argv[nextIndex + 1];
|
||||
} else {
|
||||
// Else, let next be the empty String.
|
||||
next = String::emptyString;
|
||||
next = String::emptyString();
|
||||
}
|
||||
// Let nextSub be ? ToString(next).
|
||||
String* nextSub = next.toString(state);
|
||||
|
|
@ -1481,7 +1481,7 @@ static Value builtinStringSubstr(ExecutionState& state, Value thisValue, size_t
|
|||
intStart = std::max(size + intStart, 0.0);
|
||||
double resultLength = std::min(std::max(end, 0.0), size - intStart);
|
||||
if (resultLength <= 0)
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
|
||||
return str->substring(intStart, intStart + resultLength);
|
||||
}
|
||||
|
|
@ -1511,16 +1511,16 @@ static Value builtinStringAt(ExecutionState& state, Value thisValue, size_t argc
|
|||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(anchor, state.context()->staticStrings().asciiTable[(size_t)'a'].string(), state.context()->staticStrings().name.string(), argv[0])
|
||||
// String.prototype.big ()
|
||||
// Return CreateHTML(S, "big", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(big, state.context()->staticStrings().big.string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(big, state.context()->staticStrings().big.string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.blink ()
|
||||
// Return CreateHTML(S, "blink", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(blink, state.context()->staticStrings().blink.string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(blink, state.context()->staticStrings().blink.string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.bold ()
|
||||
// Return CreateHTML(S, "b", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(bold, state.context()->staticStrings().asciiTable[(size_t)'b'].string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(bold, state.context()->staticStrings().asciiTable[(size_t)'b'].string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.fixed ()
|
||||
// Return CreateHTML(S, "tt", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(fixed, String::fromASCII("tt"), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(fixed, String::fromASCII("tt"), String::emptyString(), String::emptyString())
|
||||
// String.prototype.fontcolor (color)
|
||||
// Return CreateHTML(S, "font", "color", color).
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(fontcolor, String::fromASCII("font"), String::fromASCII("color"), argv[0])
|
||||
|
|
@ -1529,22 +1529,22 @@ DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(fontcolor, String::fromASCII("font"), Str
|
|||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(fontsize, String::fromASCII("font"), state.context()->staticStrings().size.string(), argv[0])
|
||||
// String.prototype.italics ()
|
||||
// Return CreateHTML(S, "i", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(italics, state.context()->staticStrings().asciiTable[(size_t)'i'].string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(italics, state.context()->staticStrings().asciiTable[(size_t)'i'].string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.link (url)
|
||||
// Return CreateHTML(S, "a", "href", url).
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(link, state.context()->staticStrings().asciiTable[(size_t)'a'].string(), String::fromASCII("href"), argv[0])
|
||||
// String.prototype.small ()
|
||||
// Return CreateHTML(S, "small", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(small, state.context()->staticStrings().small.string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(small, state.context()->staticStrings().small.string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.strike ()
|
||||
// Return CreateHTML(S, "strike", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(strike, state.context()->staticStrings().strike.string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(strike, state.context()->staticStrings().strike.string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.sub ()
|
||||
// Return CreateHTML(S, "sub", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(sub, state.context()->staticStrings().sub.string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(sub, state.context()->staticStrings().sub.string(), String::emptyString(), String::emptyString())
|
||||
// String.prototype.sup ()
|
||||
// Return CreateHTML(S, "sup", "", "").
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(sup, state.context()->staticStrings().sup.string(), String::emptyString, String::emptyString)
|
||||
DEFINE_STRING_ADDITIONAL_HTML_FUNCTION(sup, state.context()->staticStrings().sup.string(), String::emptyString(), String::emptyString())
|
||||
|
||||
#undef DEFINE_STRING_ADDITIONAL_HTML_FUNCTION
|
||||
|
||||
|
|
@ -1651,7 +1651,7 @@ void GlobalObject::installString(ExecutionState& state)
|
|||
m_string = new NativeFunctionObject(state, NativeFunctionInfo(strings->String, builtinStringConstructor, 1), NativeFunctionObject::__ForBuiltinConstructor__);
|
||||
m_string->setGlobalIntrinsicObject(state);
|
||||
|
||||
m_stringPrototype = new StringObject(state, m_objectPrototype, String::emptyString);
|
||||
m_stringPrototype = new StringObject(state, m_objectPrototype, String::emptyString());
|
||||
m_stringPrototype->setGlobalIntrinsicObject(state, true);
|
||||
m_string->setFunctionPrototype(state, m_stringPrototype);
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static Value TypedArraySpeciesCreate(ExecutionState& state, TypedArrayObject* ex
|
|||
Value A = Object::construct(state, C, argc, argumentList);
|
||||
TypedArrayObject::validateTypedArray(state, A);
|
||||
if (argc == 1 && argumentList[0].isNumber() && A.asObject()->asTypedArrayObject()->arrayLength() < argumentList->toNumber(state)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ static Value TypedArrayCreateSameType(ExecutionState& state, TypedArrayObject* e
|
|||
Value A = Object::construct(state, defaultConstructor, argc, argumentList);
|
||||
TypedArrayObject::validateTypedArray(state, A);
|
||||
if (argc == 1 && argumentList[0].isNumber() && A.asObject()->asTypedArrayObject()->arrayLength() < argumentList->toNumber(state)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayLength);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ static Value builtinTypedArrayFrom(ExecutionState& state, Value thisValue, size_
|
|||
Value source = argv[0];
|
||||
|
||||
if (!C.isConstructor()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_ThisNotConstructor);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_ThisNotConstructor);
|
||||
}
|
||||
|
||||
Value mapfn;
|
||||
|
|
@ -192,7 +192,7 @@ static Value builtinTypedArrayOf(ExecutionState& state, Value thisValue, size_t
|
|||
size_t len = argc;
|
||||
Value C = thisValue;
|
||||
if (!C.isConstructor()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_ThisNotConstructor);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_ThisNotConstructor);
|
||||
}
|
||||
|
||||
Value arg[1] = { Value(len) };
|
||||
|
|
@ -307,14 +307,14 @@ static void initializeTypedArrayFromArrayBuffer(ExecutionState& state, TypedArra
|
|||
size_t elementSize = obj->elementSize();
|
||||
uint64_t offset = byteOffset.toIndex(state);
|
||||
if (offset == Value::InvalidIndexValue || offset % elementSize != 0) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
|
||||
uint64_t newLength = 0;
|
||||
if (!length.isUndefined()) {
|
||||
newLength = length.toIndex(state);
|
||||
if (newLength == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -324,13 +324,13 @@ static void initializeTypedArrayFromArrayBuffer(ExecutionState& state, TypedArra
|
|||
size_t newByteLength = 0;
|
||||
if (length.isUndefined()) {
|
||||
if ((bufferByteLength % elementSize != 0) || (bufferByteLength < offset)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
newByteLength = bufferByteLength - offset;
|
||||
} else {
|
||||
newByteLength = newLength * elementSize;
|
||||
if (offset + newByteLength > bufferByteLength) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ static Value builtinTypedArrayConstructor(ExecutionState& state, Value thisValue
|
|||
if (!firstArg.isObject()) {
|
||||
uint64_t elemlen = firstArg.toIndex(state);
|
||||
if (elemlen == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_FirstArgumentInvalidLength);
|
||||
return Value();
|
||||
}
|
||||
return TA::allocateTypedArray(state, newTarget.value(), elemlen);
|
||||
|
|
@ -1398,14 +1398,14 @@ static Value builtinTypedArrayJoin(ExecutionState& state, Value thisValue, size_
|
|||
}
|
||||
|
||||
if (!state.context()->toStringRecursionPreventer()->canInvokeToString(O) || len == 0) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
ToStringRecursionPreventerItemAutoHolder holder(state, O);
|
||||
|
||||
StringBuilder builder;
|
||||
Value elem = O->getIndexedPropertyValue(state, Value(0), O);
|
||||
if (elem.isUndefinedOrNull()) {
|
||||
elem = String::emptyString;
|
||||
elem = String::emptyString();
|
||||
}
|
||||
builder.appendString(elem.toString(state), &state);
|
||||
|
||||
|
|
@ -1416,7 +1416,7 @@ static Value builtinTypedArrayJoin(ExecutionState& state, Value thisValue, size_
|
|||
}
|
||||
elem = O->getIndexedPropertyValue(state, Value(curIndex), O);
|
||||
if (elem.isUndefinedOrNull()) {
|
||||
elem = String::emptyString;
|
||||
elem = String::emptyString();
|
||||
}
|
||||
builder.appendString(elem.toString(state), &state);
|
||||
curIndex++;
|
||||
|
|
@ -1569,10 +1569,10 @@ static Value builtinTypedArrayReverse(ExecutionState& state, Value thisValue, si
|
|||
Value lowerValue = O->getIndexedPropertyValue(state, Value(lower), O);
|
||||
|
||||
if (!O->setIndexedProperty(state, Value(lower), upperValue)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
if (!O->setIndexedProperty(state, Value(upper), lowerValue)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().TypedArray.string(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
|
||||
lower++;
|
||||
|
|
@ -1652,7 +1652,7 @@ static Value builtinTypedArrayToLocaleString(ExecutionState& state, Value thisVa
|
|||
size_t len = array->arrayLength();
|
||||
|
||||
if (!state.context()->toStringRecursionPreventer()->canInvokeToString(array)) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
ToStringRecursionPreventerItemAutoHolder holder(state, array);
|
||||
|
||||
|
|
@ -1660,7 +1660,7 @@ static Value builtinTypedArrayToLocaleString(ExecutionState& state, Value thisVa
|
|||
String* separator = state.context()->staticStrings().asciiTable[(size_t)','].string();
|
||||
|
||||
// Let R be the empty String.
|
||||
String* R = String::emptyString;
|
||||
String* R = String::emptyString();
|
||||
|
||||
// Let k be 0.
|
||||
size_t k = 0;
|
||||
|
|
|
|||
|
|
@ -1012,7 +1012,7 @@ void CodeCacheReader::loadByteCodeStream(Context* context, ByteCodeBlock* block)
|
|||
switch (info.relocType) {
|
||||
case ByteCodeRelocType::RELOC_STRING: {
|
||||
if (UNLIKELY(dataIndex == SIZE_MAX)) {
|
||||
bc->m_value = String::emptyString;
|
||||
bc->m_value = String::emptyString();
|
||||
} else {
|
||||
ASSERT(dataIndex < stringLiteralData.size());
|
||||
String* string = stringLiteralData[dataIndex];
|
||||
|
|
@ -1135,7 +1135,7 @@ void CodeCacheReader::loadByteCodeStream(Context* context, ByteCodeBlock* block)
|
|||
bodyStringForLoadRegExp = false;
|
||||
} else {
|
||||
if (info.dataOffset == SIZE_MAX) {
|
||||
bc->m_option = String::emptyString;
|
||||
bc->m_option = String::emptyString();
|
||||
} else {
|
||||
ASSERT(info.dataOffset < stringLiteralData.size());
|
||||
bc->m_option = stringLiteralData[info.dataOffset];
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ struct ClassContextInformation {
|
|||
, m_prototypeIndex(SIZE_MAX)
|
||||
, m_superIndex(SIZE_MAX)
|
||||
, m_name()
|
||||
, m_src(String::emptyString)
|
||||
, m_src(String::emptyString())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ Value Interpreter::interpret(ExecutionState* state, ByteCodeBlock* byteCodeBlock
|
|||
const EncodedValueVectorElement& val = ctx->globalDeclarativeStorage()->at(idx);
|
||||
isCacheWork = true;
|
||||
if (UNLIKELY(val.isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(*state, ErrorCode::ReferenceError, ctx->globalDeclarativeRecord()->at(idx).m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(*state, ErrorCode::ReferenceError, ctx->globalDeclarativeRecord()->at(idx).m_name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
registerFile[code->m_registerIndex] = val;
|
||||
}
|
||||
|
|
@ -340,10 +340,10 @@ Value Interpreter::interpret(ExecutionState* state, ByteCodeBlock* byteCodeBlock
|
|||
const auto& record = ctx->globalDeclarativeRecord()->at(idx);
|
||||
auto& storage = ctx->globalDeclarativeStorage()->at(idx);
|
||||
if (UNLIKELY(storage.isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(*state, ErrorCode::ReferenceError, record.m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(*state, ErrorCode::ReferenceError, record.m_name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
if (UNLIKELY(!record.m_isMutable)) {
|
||||
ErrorObject::throwBuiltinError(*state, ErrorCode::TypeError, record.m_name.string(), false, String::emptyString, ErrorObject::Messages::AssignmentToConstantVariable);
|
||||
ErrorObject::throwBuiltinError(*state, ErrorCode::TypeError, record.m_name.string(), false, String::emptyString(), ErrorObject::Messages::AssignmentToConstantVariable);
|
||||
}
|
||||
storage = registerFile[code->m_registerIndex];
|
||||
}
|
||||
|
|
@ -1759,7 +1759,7 @@ NEVER_INLINE EnvironmentRecord* InterpreterSlowPath::getBindedEnvironmentRecordB
|
|||
env = env->outerEnvironment();
|
||||
}
|
||||
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -1780,7 +1780,7 @@ NEVER_INLINE Value InterpreterSlowPath::loadByName(ExecutionState& state, Lexica
|
|||
}
|
||||
|
||||
if (throwException)
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
|
||||
return Value();
|
||||
}
|
||||
|
|
@ -1796,7 +1796,7 @@ NEVER_INLINE void InterpreterSlowPath::storeByName(ExecutionState& state, Lexica
|
|||
env = env->outerEnvironment();
|
||||
}
|
||||
if (state.inStrictMode()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
}
|
||||
GlobalObject* o = state.context()->globalObject();
|
||||
o->setThrowsExceptionWhenStrictMode(state, name, value, o);
|
||||
|
|
@ -1817,7 +1817,7 @@ NEVER_INLINE void InterpreterSlowPath::initializeByName(ExecutionState& state, L
|
|||
}
|
||||
env = env->outerEnvironment();
|
||||
}
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1863,7 +1863,7 @@ NEVER_INLINE void InterpreterSlowPath::storeByNameWithAddress(ExecutionState& st
|
|||
if (idx == count) {
|
||||
EnvironmentRecord::BindingSlot slot = env->record()->hasBinding(state, code->m_name);
|
||||
if (slot.m_index == SIZE_MAX && state.inStrictMode()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, code->m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, code->m_name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
}
|
||||
env->record()->setMutableBindingByBindingSlot(state, slot, code->m_name, value);
|
||||
return;
|
||||
|
|
@ -1873,7 +1873,7 @@ NEVER_INLINE void InterpreterSlowPath::storeByNameWithAddress(ExecutionState& st
|
|||
}
|
||||
}
|
||||
if (state.inStrictMode()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, code->m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, code->m_name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
}
|
||||
GlobalObject* o = state.context()->globalObject();
|
||||
o->setThrowsExceptionWhenStrictMode(state, code->m_name, value, o);
|
||||
|
|
@ -2199,7 +2199,7 @@ NEVER_INLINE void InterpreterSlowPath::deleteOperation(ExecutionState& state, Le
|
|||
const Value& o = state.makeSuperPropertyReference();
|
||||
Object* obj = o.toObject(state);
|
||||
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.toObjectStructurePropertyName(state).toExceptionString(), false, String::emptyString, "ReferenceError: Unsupported reference to 'super'");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.toObjectStructurePropertyName(state).toExceptionString(), false, String::emptyString(), "ReferenceError: Unsupported reference to 'super'");
|
||||
} else {
|
||||
const Value& o = registerFile[code->m_srcIndex0];
|
||||
const Value& p = registerFile[code->m_srcIndex1];
|
||||
|
|
@ -2710,7 +2710,7 @@ NEVER_INLINE void InterpreterSlowPath::setObjectPreComputedCaseOperationCacheMis
|
|||
if (code->m_isLength && originalObject->isArrayObject()) {
|
||||
if (LIKELY(originalObject->asArrayObject()->isFastModeArray())) {
|
||||
if (!originalObject->asArrayObject()->setArrayLength(state, value) && state.inStrictMode()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, code->m_propertyName.toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, code->m_propertyName.toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
} else {
|
||||
originalObject->setThrowsExceptionWhenStrictMode(state, ObjectPropertyName(state, code->m_propertyName), value, willBeObject);
|
||||
|
|
@ -2931,7 +2931,7 @@ NEVER_INLINE Value InterpreterSlowPath::getGlobalVariableSlowCase(ExecutionState
|
|||
slot->m_cachedStructure = nullptr;
|
||||
auto v = (*state.context()->globalDeclarativeStorage())[i];
|
||||
if (UNLIKELY(v.isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
|
@ -2948,7 +2948,7 @@ NEVER_INLINE Value InterpreterSlowPath::getGlobalVariableSlowCase(ExecutionState
|
|||
if (!virtialIdResult.isEmpty())
|
||||
return virtialIdResult;
|
||||
}
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
ASSERT_NOT_REACHED();
|
||||
return Value(Value::EmptyValue);
|
||||
}
|
||||
|
|
@ -2981,7 +2981,7 @@ NEVER_INLINE void InterpreterSlowPath::setGlobalVariableSlowCase(ExecutionState&
|
|||
slot->m_cachedStructure = nullptr;
|
||||
auto& place = (*ctx->globalDeclarativeStorage())[i];
|
||||
if (UNLIKELY(place.isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
if (UNLIKELY(!records[i].m_isMutable)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ErrorObject::Messages::AssignmentToConstantVariable, name);
|
||||
|
|
@ -2995,7 +2995,7 @@ NEVER_INLINE void InterpreterSlowPath::setGlobalVariableSlowCase(ExecutionState&
|
|||
auto findResult = go->structure()->findProperty(slot->m_propertyName);
|
||||
if (UNLIKELY(findResult.first == SIZE_MAX)) {
|
||||
if (UNLIKELY(state.inStrictMode())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, slot->m_propertyName.string(), false, String::emptyString, ErrorObject::Messages::IsNotDefined);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, slot->m_propertyName.string(), false, String::emptyString(), ErrorObject::Messages::IsNotDefined);
|
||||
}
|
||||
VirtualIdDisabler d(state.context());
|
||||
go->setThrowsExceptionWhenStrictMode(state, ObjectPropertyName(state, slot->m_propertyName), value, go);
|
||||
|
|
@ -3585,7 +3585,7 @@ NEVER_INLINE void InterpreterSlowPath::initializeClassOperation(ExecutionState&
|
|||
outerClassConstructor, code->m_classSrc, name);
|
||||
} else {
|
||||
if (!heritagePresent) {
|
||||
Value argv[] = { String::emptyString, String::emptyString };
|
||||
Value argv[] = { String::emptyString(), String::emptyString() };
|
||||
auto functionSource = FunctionObject::createDynamicFunctionScript(state, state.context()->staticStrings().constructor, 1, &argv[0], argv[1], true, false, false, false, true);
|
||||
functionSource.codeBlock->setAsClassConstructor();
|
||||
constructor = new ScriptClassConstructorFunctionObject(state, constructorParent.asObject(),
|
||||
|
|
@ -3709,7 +3709,7 @@ NEVER_INLINE void InterpreterSlowPath::complexSetObjectOperation(ExecutionState&
|
|||
// testing is strict mode || IsStrictReference(V)
|
||||
// IsStrictReference returns true if code is class method
|
||||
if (state.inStrictMode() || !state.resolveCallee()->codeBlock()->asInterpretedCodeBlock()->isObjectMethod()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ObjectPropertyName(state, registerFile[code->m_propertyNameIndex]).toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ObjectPropertyName(state, registerFile[code->m_propertyNameIndex]).toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -4212,7 +4212,7 @@ NEVER_INLINE void InterpreterSlowPath::callFunctionComplexCase(ExecutionState& s
|
|||
auto promiseCapability = PromiseObject::newPromiseCapability(state, state.context()->globalObject()->promise());
|
||||
|
||||
// Let specifierString be ToString(specifier).
|
||||
String* specifierString = String::emptyString;
|
||||
String* specifierString = String::emptyString();
|
||||
// IfAbruptRejectPromise(specifierString, promiseCapability).
|
||||
try {
|
||||
specifierString = specifier.toString(state);
|
||||
|
|
@ -5051,12 +5051,12 @@ NEVER_INLINE int InterpreterSlowPath::evaluateImportAssertionOperation(Execution
|
|||
// Currently only "type" is supported
|
||||
if (!key.isString() || !key.asString()->equals("type")) {
|
||||
String* asString = key.toStringWithoutException(state);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, asString, false, String::emptyString, "unsupported import assertion key: %s");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, asString, false, String::emptyString(), "unsupported import assertion key: %s");
|
||||
}
|
||||
|
||||
if (!resultValue.isString() || !resultValue.asString()->equals("json")) {
|
||||
String* asString = resultValue.toStringWithoutException(state);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, asString, false, String::emptyString, "unsupported import assertion type: %s");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, asString, false, String::emptyString(), "unsupported import assertion type: %s");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1842,7 +1842,7 @@ static String* bestAvailableLocale(ExecutionState& state, const Vector<String*,
|
|||
// Let pos be the character index of the last occurrence of "-" (U+002D) within candidate. If that character does not occur, return undefined.
|
||||
size_t pos = candidate->rfind(state.context()->staticStrings().asciiTable[(size_t)'-'].string(), candidate->length() - 1);
|
||||
if (pos == SIZE_MAX)
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
|
||||
// If pos ≥ 2 and the character "-" occurs at index pos-2 of candidate, then decrease pos by 2.
|
||||
if (pos >= 2 && candidate->charAt(pos - 2) == '-')
|
||||
|
|
@ -1852,7 +1852,7 @@ static String* bestAvailableLocale(ExecutionState& state, const Vector<String*,
|
|||
candidate = candidate->substring(0, pos);
|
||||
}
|
||||
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
static Intl::IntlMatcherResult lookupMatcher(ExecutionState& state, const Vector<String*, GCUtil::gc_malloc_allocator<String*>> availableLocales, const ValueVector& requestedLocales)
|
||||
|
|
@ -1863,10 +1863,10 @@ static Intl::IntlMatcherResult lookupMatcher(ExecutionState& state, const Vector
|
|||
// Let len be the number of elements in requestedLocales.
|
||||
size_t len = requestedLocales.size();
|
||||
// Let availableLocale be undefined.
|
||||
String* availableLocale = String::emptyString;
|
||||
String* availableLocale = String::emptyString();
|
||||
|
||||
String* locale = String::emptyString;
|
||||
String* noExtensionsLocale = String::emptyString;
|
||||
String* locale = String::emptyString();
|
||||
String* noExtensionsLocale = String::emptyString();
|
||||
|
||||
// Repeat while i < len and availableLocale is undefined:
|
||||
while (i < len && availableLocale->length() == 0) {
|
||||
|
|
@ -2004,7 +2004,7 @@ static Optional<String*> unicodeExtensionValue(ExecutionState& state, String* ex
|
|||
pos = extension->find(searchValue);
|
||||
// If pos ≠ -1 and pos + 3 = size, then
|
||||
if (pos != SIZE_MAX && pos + 3 == size) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
|
@ -2069,7 +2069,7 @@ StringMap Intl::resolveLocale(ExecutionState& state, const Vector<String*, GCUti
|
|||
std::string value = keyLocaleData[0];
|
||||
|
||||
// Let supportedExtensionAddition be "".
|
||||
String* supportedExtensionAddition = String::emptyString;
|
||||
String* supportedExtensionAddition = String::emptyString();
|
||||
|
||||
// If r has an [[extension]] field, then
|
||||
if (r.extension->length()) {
|
||||
|
|
@ -2117,7 +2117,7 @@ StringMap Intl::resolveLocale(ExecutionState& state, const Vector<String*, GCUti
|
|||
// Let value be optionsValue.
|
||||
value = optionsValue->toNonGCUTF8StringData();
|
||||
// Let supportedExtensionAddition be "".
|
||||
supportedExtensionAddition = String::emptyString;
|
||||
supportedExtensionAddition = String::emptyString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2152,7 +2152,7 @@ StringMap Intl::resolveLocale(ExecutionState& state, const Vector<String*, GCUti
|
|||
String* preExtension = foundLocale->substring(0, len > r.extensionIndex ? r.extensionIndex : len);
|
||||
|
||||
// Let postExtension be the substring of foundLocale from position extensionIndex to the end of the string.
|
||||
String* postExtension = String::emptyString;
|
||||
String* postExtension = String::emptyString();
|
||||
if (r.extensionIndex < len) {
|
||||
postExtension = foundLocale->substring(r.extensionIndex, len);
|
||||
}
|
||||
|
|
@ -2554,7 +2554,7 @@ String* Intl::icuNumberFieldToString(ExecutionState& state, int32_t fieldName, d
|
|||
return state.context()->staticStrings().lazyCompact().string();
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public:
|
|||
struct IntlMatcherResult {
|
||||
IntlMatcherResult()
|
||||
{
|
||||
extension = locale = String::emptyString;
|
||||
extension = locale = String::emptyString();
|
||||
extensionIndex = SIZE_MAX;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ static String* canonicalizeTimeZoneName(ExecutionState& state, String* timeZoneN
|
|||
UEnumeration* timeZones = ucal_openTimeZones(&status);
|
||||
ASSERT(U_SUCCESS(status));
|
||||
|
||||
String* canonical = String::emptyString;
|
||||
String* canonical = String::emptyString();
|
||||
do {
|
||||
status = U_ZERO_ERROR;
|
||||
int32_t ianaTimeZoneLength;
|
||||
|
|
@ -301,7 +301,7 @@ static String* icuFieldTypeToPartName(ExecutionState& state, int32_t fieldName)
|
|||
return state.context()->staticStrings().lazyFractionalSecond().string();
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -312,10 +312,10 @@ IntlDateTimeFormatObject::IntlDateTimeFormatObject(ExecutionState& state, Value
|
|||
|
||||
IntlDateTimeFormatObject::IntlDateTimeFormatObject(ExecutionState& state, Object* proto, Value locales, Value options)
|
||||
: DerivedObject(state, proto)
|
||||
, m_locale(String::emptyString)
|
||||
, m_calendar(String::emptyString)
|
||||
, m_numberingSystem(String::emptyString)
|
||||
, m_timeZone(String::emptyString)
|
||||
, m_locale(String::emptyString())
|
||||
, m_calendar(String::emptyString())
|
||||
, m_numberingSystem(String::emptyString())
|
||||
, m_timeZone(String::emptyString())
|
||||
, m_icuDateFormat(nullptr)
|
||||
{
|
||||
// Let requestedLocales be ? CanonicalizeLocaleList(locales).
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ public:
|
|||
if (sd.size()) {
|
||||
value = new UTF16String(std::move(sd));
|
||||
} else {
|
||||
value = String::emptyString;
|
||||
value = String::emptyString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -859,7 +859,7 @@ public:
|
|||
if (sd.size()) {
|
||||
value = new UTF16String(std::move(sd));
|
||||
} else {
|
||||
value = String::emptyString;
|
||||
value = String::emptyString();
|
||||
}
|
||||
elements.append(m_allocator, new (m_allocator) LiteralNode(value));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1960,7 +1960,7 @@ String* Scanner::scanRegExpFlags()
|
|||
}
|
||||
|
||||
if (!flags.length()) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
if (isAllASCII(flags.data(), flags.length())) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public:
|
|||
ALWAYS_INLINE ParserStringView()
|
||||
: String()
|
||||
{
|
||||
initBufferAccessData(String::emptyString->bufferAccessData(), 0, 0);
|
||||
initBufferAccessData(String::emptyString()->bufferAccessData(), 0, 0);
|
||||
}
|
||||
|
||||
template <const size_t srcLen>
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ Value Script::execute(ExecutionState& state, bool isExecuteOnEvalFunction, bool
|
|||
// If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError
|
||||
for (size_t j = 0; j < identifierVectorLen; j++) {
|
||||
if (identifierVector[j].m_isVarDeclaration && identifierVector[j].m_name == globalDeclarativeRecord->at(i).m_name) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, globalDeclarativeRecord->at(i).m_name.string(), false, String::emptyString, ErrorObject::Messages::DuplicatedIdentifier);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, globalDeclarativeRecord->at(i).m_name.string(), false, String::emptyString(), ErrorObject::Messages::DuplicatedIdentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -444,7 +444,7 @@ Value Script::execute(ExecutionState& state, bool isExecuteOnEvalFunction, bool
|
|||
// If hasRestrictedGlobal is true, throw a SyntaxError exception.
|
||||
auto desc = context()->globalObject()->getOwnProperty(state, globalLexicalVector[i].m_name);
|
||||
if (desc.hasValue() && !desc.isConfigurable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, globalLexicalVector[i].m_name.string(), false, String::emptyString, "redeclaration of non-configurable global property %s");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, globalLexicalVector[i].m_name.string(), false, String::emptyString(), "redeclaration of non-configurable global property %s");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -553,7 +553,7 @@ Value Script::executeLocal(ExecutionState& state, Value thisValue, InterpretedCo
|
|||
if (vec[i].m_isVarDeclaration) {
|
||||
auto slot = e->record()->hasBinding(state, vec[i].m_name);
|
||||
if (slot.m_isLexicallyDeclared && slot.m_index != SIZE_MAX) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, vec[i].m_name.string(), false, String::emptyString, ErrorObject::Messages::DuplicatedIdentifier);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, vec[i].m_name.string(), false, String::emptyString(), ErrorObject::Messages::DuplicatedIdentifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ ScriptParser::ScriptParser(Context* c)
|
|||
|
||||
ScriptParser::InitializeScriptResult::InitializeScriptResult()
|
||||
: parseErrorCode(ErrorCode::None)
|
||||
, parseErrorMessage(String::emptyString)
|
||||
, parseErrorMessage(String::emptyString())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
codeBlock->m_stringLiteralData.pushBack(m_value.asPointerValue()->asString());
|
||||
} else {
|
||||
// change the value as empty string
|
||||
m_value = String::emptyString;
|
||||
m_value = String::emptyString();
|
||||
}
|
||||
} else {
|
||||
ASSERT(m_value.asPointerValue()->isBigInt());
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public:
|
|||
codeBlock->m_stringLiteralData.push_back(str);
|
||||
value = str;
|
||||
} else {
|
||||
value = String::emptyString;
|
||||
value = String::emptyString();
|
||||
}
|
||||
}
|
||||
codeBlock->pushCode(LoadLiteral(ByteCodeLOC(m_loc.index), dstRegister, value), context, this->m_loc.index);
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ namespace Escargot {
|
|||
namespace esprima {
|
||||
|
||||
Error::Error(String* message)
|
||||
: name(String::emptyString)
|
||||
: name(String::emptyString())
|
||||
, message(message)
|
||||
, index(0)
|
||||
, lineNumber(0)
|
||||
, column(0)
|
||||
, description(String::emptyString)
|
||||
, description(String::emptyString())
|
||||
, errorCode(ErrorCode::SyntaxError)
|
||||
{
|
||||
}
|
||||
|
|
@ -528,7 +528,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void throwError(const char* messageFormat, String* arg0 = String::emptyString, String* arg1 = String::emptyString, ErrorCode code = ErrorCode::SyntaxError)
|
||||
void throwError(const char* messageFormat, String* arg0 = String::emptyString(), String* arg1 = String::emptyString(), ErrorCode code = ErrorCode::SyntaxError)
|
||||
{
|
||||
UTF16StringDataNonGCStd msg;
|
||||
if (arg0->length() && arg1->length()) {
|
||||
|
|
@ -935,7 +935,7 @@ public:
|
|||
#else
|
||||
if (UNLIKELY(currentStackBase > stackLimit)) {
|
||||
#endif
|
||||
this->throwError("too many recursion in script", String::emptyString, String::emptyString, ErrorCode::RangeError);
|
||||
this->throwError("too many recursion in script", String::emptyString(), String::emptyString(), ErrorCode::RangeError);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3641,7 +3641,7 @@ public:
|
|||
void openBlock(ParserBlockContext& ctx)
|
||||
{
|
||||
if (UNLIKELY(this->lexicalBlockCount == LEXICAL_BLOCK_INDEX_MAX - 1)) {
|
||||
this->throwError("too many lexical blocks in script", String::emptyString, String::emptyString, ErrorCode::RangeError);
|
||||
this->throwError("too many lexical blocks in script", String::emptyString(), String::emptyString(), ErrorCode::RangeError);
|
||||
}
|
||||
|
||||
this->lastUsingName = AtomicString();
|
||||
|
|
@ -6173,7 +6173,7 @@ public:
|
|||
this->expect(RightBrace);
|
||||
|
||||
if (UNLIKELY(fieldCount > std::numeric_limits<uint16_t>::max())) {
|
||||
this->throwError("too many fields in class", String::emptyString, String::emptyString, ErrorCode::RangeError);
|
||||
this->throwError("too many fields in class", String::emptyString(), String::emptyString(), ErrorCode::RangeError);
|
||||
}
|
||||
|
||||
if (privateNames.size() && !this->isParsingSingleFunction) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ ArrayBufferObject* ArrayBufferObject::allocateArrayBuffer(ExecutionState& state,
|
|||
});
|
||||
|
||||
if (UNLIKELY(byteLength >= ArrayBuffer::maxArrayBufferSize)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
}
|
||||
|
||||
ArrayBufferObject* obj = new ArrayBufferObject(state, proto);
|
||||
|
|
@ -44,7 +44,7 @@ ArrayBufferObject* ArrayBufferObject::allocateArrayBuffer(ExecutionState& state,
|
|||
ASSERT(byteLength <= maxByteLength.value());
|
||||
uint64_t maxLength = maxByteLength.value();
|
||||
if (UNLIKELY(maxLength >= ArrayBuffer::maxArrayBufferSize)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().ArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
}
|
||||
|
||||
// allocate default resizable non-shared BackingStore
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class AtomicString : public gc {
|
|||
|
||||
public:
|
||||
inline AtomicString()
|
||||
: m_string(String::emptyString)
|
||||
: m_string(String::emptyString())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ String* BigInt::toString(int radix)
|
|||
m_bf.sign = savedSign;
|
||||
|
||||
if (UNLIKELY(!str)) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
} else {
|
||||
String* ret = String::fromASCII(str, resultLen);
|
||||
bf_free(ThreadLocal::bfContext(), str);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public:
|
|||
bool valid;
|
||||
|
||||
RegExpLegacyFeatures()
|
||||
: input(String::emptyString)
|
||||
: input(String::emptyString())
|
||||
, lastMatch()
|
||||
, lastParen()
|
||||
, leftContext()
|
||||
|
|
@ -120,7 +120,7 @@ public:
|
|||
|
||||
void invalidate()
|
||||
{
|
||||
input = String::emptyString;
|
||||
input = String::emptyString();
|
||||
lastMatch = StringView();
|
||||
lastParen = StringView();
|
||||
leftContext = StringView();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public:
|
|||
void throwTypeErrorIfDetached(ExecutionState& state)
|
||||
{
|
||||
if (UNLIKELY(rawBuffer() == nullptr)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_DetachedBuffer);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_DetachedBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ public:
|
|||
{
|
||||
double numberIndex = index.toIndex(state);
|
||||
if (numberIndex == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
|
||||
throwTypeErrorIfDetached(state);
|
||||
|
|
@ -75,7 +75,7 @@ public:
|
|||
size_t elementSize = TypedArrayHelper::elementSize(type);
|
||||
|
||||
if (numberIndex + elementSize > viewSize) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_RangeError);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_RangeError);
|
||||
}
|
||||
|
||||
size_t bufferIndex = numberIndex + viewOffset;
|
||||
|
|
@ -87,7 +87,7 @@ public:
|
|||
{
|
||||
double numberIndex = index.toIndex(state);
|
||||
if (numberIndex == Value::InvalidIndexValue) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
|
||||
}
|
||||
|
||||
auto numericValue = val.toNumeric(state);
|
||||
|
|
@ -101,7 +101,7 @@ public:
|
|||
size_t elementSize = TypedArrayHelper::elementSize(type);
|
||||
|
||||
if (numberIndex + elementSize > viewSize) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_RangeError);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_RangeError);
|
||||
}
|
||||
|
||||
size_t bufferIndex = numberIndex + viewOffset;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ void GlobalEnvironmentRecord::createBinding(ExecutionState& state, const AtomicS
|
|||
{
|
||||
for (size_t i = 0; i < m_globalDeclarativeRecord->size(); i++) {
|
||||
if (m_globalDeclarativeRecord->at(i).m_name == name) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, name.string(), false, String::emptyString, ErrorObject::Messages::DuplicatedIdentifier);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, name.string(), false, String::emptyString(), ErrorObject::Messages::DuplicatedIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ EnvironmentRecord::GetBindingValueResult GlobalEnvironmentRecord::getBindingValu
|
|||
for (size_t i = 0; i < m_globalDeclarativeRecord->size(); i++) {
|
||||
if (m_globalDeclarativeRecord->at(i).m_name == name) {
|
||||
if (UNLIKELY(m_globalDeclarativeStorage->at(i).isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
return EnvironmentRecord::GetBindingValueResult(true, m_globalDeclarativeStorage->at(i));
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ void GlobalEnvironmentRecord::setMutableBinding(ExecutionState& state, const Ato
|
|||
for (size_t i = 0; i < m_globalDeclarativeRecord->size(); i++) {
|
||||
if (m_globalDeclarativeRecord->at(i).m_name == name) {
|
||||
if (UNLIKELY(m_globalDeclarativeStorage->at(i).isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
m_globalDeclarativeStorage->at(i) = V;
|
||||
return;
|
||||
|
|
@ -128,7 +128,7 @@ void GlobalEnvironmentRecord::setMutableBindingByBindingSlot(ExecutionState& sta
|
|||
if (slot.m_index != SIZE_MAX - 1) {
|
||||
// TDZ check
|
||||
if (UNLIKELY(m_globalDeclarativeStorage->at(slot.m_index).isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
|
||||
// Storing to const variable check
|
||||
|
|
@ -208,7 +208,7 @@ void DeclarativeEnvironmentRecordNotIndexed::createBinding(ExecutionState& state
|
|||
auto hasBindingResult = hasBinding(state, name);
|
||||
if (UNLIKELY(hasBindingResult.m_index != SIZE_MAX)) {
|
||||
if (!m_recordVector[hasBindingResult.m_index].m_isVarDeclaration || !isVarDeclaration) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, name.string(), false, String::emptyString, ErrorObject::Messages::DuplicatedIdentifier);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, name.string(), false, String::emptyString(), ErrorObject::Messages::DuplicatedIdentifier);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ EnvironmentRecord::GetBindingValueResult DeclarativeEnvironmentRecordNotIndexed:
|
|||
for (size_t i = 0; i < len; i++) {
|
||||
if (m_recordVector[i].m_name == name) {
|
||||
if (UNLIKELY(m_heapStorage[i].isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
return EnvironmentRecord::GetBindingValueResult(m_heapStorage[i]);
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ void DeclarativeEnvironmentRecordNotIndexed::setMutableBinding(ExecutionState& s
|
|||
for (size_t i = 0; i < len; i++) {
|
||||
if (m_recordVector[i].m_name == name) {
|
||||
if (UNLIKELY(m_heapStorage[i].isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
if (UNLIKELY(!m_recordVector[i].m_isMutable)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, ErrorObject::Messages::AssignmentToConstantVariable, name);
|
||||
|
|
@ -261,7 +261,7 @@ void DeclarativeEnvironmentRecordNotIndexed::setMutableBindingByBindingSlot(Exec
|
|||
{
|
||||
// TDZ check
|
||||
if (UNLIKELY(m_heapStorage[slot.m_index].isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
|
||||
// Storing to const variable check
|
||||
|
|
@ -466,7 +466,7 @@ void ModuleEnvironmentRecord::createBinding(ExecutionState& state, const AtomicS
|
|||
auto hasBindingResult = hasBinding(state, name);
|
||||
if (UNLIKELY(hasBindingResult.m_index != SIZE_MAX)) {
|
||||
if (!m_moduleBindings[hasBindingResult.m_index].m_isVarDeclaration || !isVarDeclaration) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, name.string(), false, String::emptyString, ErrorObject::Messages::DuplicatedIdentifier);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::SyntaxError, name.string(), false, String::emptyString(), ErrorObject::Messages::DuplicatedIdentifier);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -506,7 +506,7 @@ public:
|
|||
for (size_t i = 0; i < v.size(); i++) {
|
||||
if (!v[i].m_needToAllocateOnStack) {
|
||||
if (cnt == idx) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, v[i].m_name.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, v[i].m_name.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
|
|
@ -1257,7 +1257,7 @@ protected:
|
|||
void readCheck(ExecutionState& state, const size_t i)
|
||||
{
|
||||
if (UNLIKELY(m_moduleBindings[i].m_value.isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, m_moduleBindings[i].m_localName.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, m_moduleBindings[i].m_localName.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1268,7 +1268,7 @@ protected:
|
|||
}
|
||||
|
||||
if (UNLIKELY(!m_moduleBindings[i].m_isVarDeclaration && m_moduleBindings[i].m_value.isEmpty())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, m_moduleBindings[i].m_localName.string(), false, String::emptyString, ErrorObject::Messages::IsNotInitialized);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::ReferenceError, m_moduleBindings[i].m_localName.string(), false, String::emptyString(), ErrorObject::Messages::IsNotInitialized);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static Value builtinErrorObjectStackInfoGet(ExecutionState& state, Value thisVal
|
|||
|
||||
ErrorObject* obj = thisValue.asObject()->asErrorObject();
|
||||
if (!obj->stackTraceData()) {
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
auto stackTraceData = obj->stackTraceData().value();
|
||||
|
|
|
|||
|
|
@ -149,22 +149,22 @@ public:
|
|||
|
||||
static void throwBuiltinError(ExecutionState& state, ErrorCode code, const char* templateString)
|
||||
{
|
||||
throwBuiltinError(state, code, String::emptyString, false, String::emptyString, templateString);
|
||||
throwBuiltinError(state, code, String::emptyString(), false, String::emptyString(), templateString);
|
||||
}
|
||||
|
||||
static void throwBuiltinError(ExecutionState& state, ErrorCode code, const char* templateString, AtomicString templateDataString)
|
||||
{
|
||||
throwBuiltinError(state, code, templateDataString.string(), false, String::emptyString, templateString);
|
||||
throwBuiltinError(state, code, templateDataString.string(), false, String::emptyString(), templateString);
|
||||
}
|
||||
|
||||
static void throwBuiltinError(ExecutionState& state, ErrorCode code, const char* templateString, String* templateDataString)
|
||||
{
|
||||
throwBuiltinError(state, code, templateDataString, false, String::emptyString, templateString);
|
||||
throwBuiltinError(state, code, templateDataString, false, String::emptyString(), templateString);
|
||||
}
|
||||
|
||||
static ErrorObject* createBuiltinError(ExecutionState& state, ErrorCode code, const char* templateString, bool fillStackInfo = true)
|
||||
{
|
||||
return createBuiltinError(state, code, String::emptyString, false, String::emptyString, templateString, fillStackInfo);
|
||||
return createBuiltinError(state, code, String::emptyString(), false, String::emptyString(), templateString, fillStackInfo);
|
||||
}
|
||||
|
||||
static ErrorObject* createError(ExecutionState& state, ErrorCode code, String* errorMessage, bool fillStackInfo = true);
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ public:
|
|||
};
|
||||
|
||||
// create a script for dynamic function
|
||||
static FunctionSource createDynamicFunctionScript(ExecutionState& state, AtomicString functionName, size_t argCount, Value* argArray, Value bodyString, bool useStrict, bool isGenerator, bool isAsync, bool allowSuperCall, bool isInternalSource = false, String* sourceName = String::emptyString);
|
||||
static FunctionSource createDynamicFunctionScript(ExecutionState& state, AtomicString functionName, size_t argCount, Value* argArray, Value bodyString, bool useStrict, bool isGenerator, bool isAsync, bool allowSuperCall, bool isInternalSource = false, String* sourceName = String::emptyString());
|
||||
// create a general function script which is not a dynamic function
|
||||
static ScriptParser::InitializeScriptResult createFunctionScript(ExecutionState& state, String* sourceName, AtomicString functionName, size_t argCount, Value* argArray, Value bodyString, bool useStrict);
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ Value JSON::parse(ExecutionState& state, Value text, Value reviver)
|
|||
if (reviver.isCallable()) {
|
||||
Object* root = new Object(state);
|
||||
root->markThisObjectDontNeedStructureTransitionTable();
|
||||
root->defineOwnProperty(state, ObjectPropertyName(state, String::emptyString), ObjectPropertyDescriptor(unfiltered, ObjectPropertyDescriptor::AllPresent));
|
||||
root->defineOwnProperty(state, ObjectPropertyName(state, String::emptyString()), ObjectPropertyDescriptor(unfiltered, ObjectPropertyDescriptor::AllPresent));
|
||||
std::function<Value(Value, const ObjectPropertyName&)> Walk;
|
||||
Walk = [&](Value holder, const ObjectPropertyName& name) -> Value {
|
||||
CHECK_STACK_OVERFLOW(state);
|
||||
|
|
@ -284,7 +284,7 @@ Value JSON::parse(ExecutionState& state, Value text, Value reviver)
|
|||
Value arguments[] = { name.toPlainValue(), val };
|
||||
return Object::call(state, reviver, holder, 2, arguments);
|
||||
};
|
||||
return Walk(root, ObjectPropertyName(state, String::emptyString));
|
||||
return Walk(root, ObjectPropertyName(state, String::emptyString()));
|
||||
}
|
||||
|
||||
// 5
|
||||
|
|
@ -691,7 +691,7 @@ Value JSON::stringify(ExecutionState& state, Value value, Value replacer, Value
|
|||
auto strings = &state.context()->staticStrings();
|
||||
|
||||
// 1, 2, 3
|
||||
String* indent = String::emptyString;
|
||||
String* indent = String::emptyString();
|
||||
ValueVectorWithInlineStorage stack;
|
||||
ValueVectorWithInlineStorage propertyList;
|
||||
bool propertyListTouched = false;
|
||||
|
|
@ -744,7 +744,7 @@ Value JSON::stringify(ExecutionState& state, Value value, Value replacer, Value
|
|||
}
|
||||
|
||||
// 6, 7, 8
|
||||
String* gap = String::emptyString;
|
||||
String* gap = String::emptyString();
|
||||
if (space.isNumber()) {
|
||||
int space_cnt = std::min(space.toInteger(state), 10.0);
|
||||
if (space_cnt >= 1) {
|
||||
|
|
@ -766,9 +766,9 @@ Value JSON::stringify(ExecutionState& state, Value value, Value replacer, Value
|
|||
// 9
|
||||
Object* wrapper = new Object(state);
|
||||
// 10
|
||||
wrapper->defineOwnProperty(state, ObjectPropertyName(state, String::emptyString), ObjectPropertyDescriptor(value, ObjectPropertyDescriptor::AllPresent));
|
||||
wrapper->defineOwnProperty(state, ObjectPropertyName(state, String::emptyString()), ObjectPropertyDescriptor(value, ObjectPropertyDescriptor::AllPresent));
|
||||
LargeStringBuilder product;
|
||||
auto ret = builtinJSONStringifyStr(state, String::emptyString, wrapper, strings, replacerFunc, stack, indent, gap, propertyListTouched, propertyList, product);
|
||||
auto ret = builtinJSONStringifyStr(state, String::emptyString(), wrapper, strings, replacerFunc, stack, indent, gap, propertyListTouched, propertyList, product);
|
||||
if (ret) {
|
||||
return product.finalize(&state);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1284,7 +1284,7 @@ Optional<Object*> Object::getMethod(ExecutionState& state, const ObjectPropertyN
|
|||
}
|
||||
// 5. If IsCallable(func) is false, throw a TypeError exception.
|
||||
if (!func.isCallable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::emptyString, false, String::emptyString, "%s: return value of getMethod is not callable");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, String::emptyString(), false, String::emptyString(), "%s: return value of getMethod is not callable");
|
||||
}
|
||||
// 6. Return func.
|
||||
return Optional<Object*>(func.asObject());
|
||||
|
|
@ -1563,30 +1563,30 @@ bool Object::isCompatiblePropertyDescriptor(ExecutionState& state, bool extensib
|
|||
void Object::setThrowsException(ExecutionState& state, const ObjectPropertyName& P, const Value& v, const Value& receiver)
|
||||
{
|
||||
if (UNLIKELY(!set(state, P, v, receiver))) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::setThrowsExceptionWhenStrictMode(ExecutionState& state, const ObjectPropertyName& P, const Value& v, const Value& receiver)
|
||||
{
|
||||
if (UNLIKELY(!set(state, P, v, receiver)) && state.inStrictMode()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
}
|
||||
|
||||
void Object::throwCannotDefineError(ExecutionState& state, const ObjectStructurePropertyName& P)
|
||||
{
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_RedefineNotConfigurable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_RedefineNotConfigurable);
|
||||
}
|
||||
|
||||
void Object::throwCannotWriteError(ExecutionState& state, const ObjectStructurePropertyName& P)
|
||||
{
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotWritable);
|
||||
}
|
||||
|
||||
void Object::throwCannotDeleteError(ExecutionState& state, const ObjectStructurePropertyName& P)
|
||||
{
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString, ErrorObject::Messages::DefineProperty_NotConfigurable);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, P.toExceptionString(), false, String::emptyString(), ErrorObject::Messages::DefineProperty_NotConfigurable);
|
||||
}
|
||||
|
||||
ArrayObject* Object::createArrayFromList(ExecutionState& state, const uint64_t& size, const Value* buffer)
|
||||
|
|
@ -1646,7 +1646,7 @@ ValueVector Object::createListFromArrayLike(ExecutionState& state, Value obj, ui
|
|||
}
|
||||
|
||||
if (UNLIKELY(!validType)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->object.string(), false, String::emptyString, "%s: Type(next) is not an element of elementTypes");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->object.string(), false, String::emptyString(), "%s: Type(next) is not an element of elementTypes");
|
||||
}
|
||||
|
||||
// Append next as the last element of list.
|
||||
|
|
@ -1708,7 +1708,7 @@ bool Object::isArray(ExecutionState& state)
|
|||
if (isProxyObject()) {
|
||||
ProxyObject* proxy = asProxyObject();
|
||||
if (proxy->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().Proxy.string(), false, String::emptyString, "%s: Proxy handler should not null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not null.");
|
||||
return false;
|
||||
}
|
||||
if (proxy->target() == nullptr) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void* ProxyObject::operator new(size_t size)
|
|||
Context* ProxyObject::getFunctionRealm(ExecutionState& state)
|
||||
{
|
||||
if (m_handler == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, state.context()->staticStrings().Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -68,12 +68,12 @@ ProxyObject* ProxyObject::createProxy(ExecutionState& state, const Value& target
|
|||
|
||||
// If Type(target) is not Object, throw a TypeError exception.
|
||||
if (!target.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: \'target\' argument of Proxy must be an object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: \'target\' argument of Proxy must be an object");
|
||||
}
|
||||
|
||||
// If Type(handler) is not Object, throw a TypeError exception.
|
||||
if (!handler.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: \'handler\' argument of Proxy must be an object");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: \'handler\' argument of Proxy must be an object");
|
||||
}
|
||||
|
||||
// Let P be ! MakeBasicObject(« [[ProxyHandler]], [[ProxyTarget]] »).
|
||||
|
|
@ -106,7 +106,7 @@ bool ProxyObject::defineOwnProperty(ExecutionState& state, const ObjectPropertyN
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ bool ProxyObject::defineOwnProperty(ExecutionState& state, const ObjectPropertyN
|
|||
// b. If settingConfigFalse is true, throw a TypeError exception.
|
||||
if (!targetDesc.hasValue()) {
|
||||
if (!extensibleTarget || settingConfigFalse) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -169,12 +169,12 @@ bool ProxyObject::defineOwnProperty(ExecutionState& state, const ObjectPropertyN
|
|||
// a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc , targetDesc) is false, throw a TypeError exception.
|
||||
// b. If settingConfigFalse is true and targetDesc.[[Configurable]] is true, throw a TypeError exception.
|
||||
if (!Object::isCompatiblePropertyDescriptor(state, extensibleTarget, desc, targetDesc) || (settingConfigFalse && targetDesc.isConfigurable())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
if (targetDesc.isDataProperty() && !targetDesc.isConfigurable() && targetDesc.isWritable()) {
|
||||
if (desc.isWritablePresent() && !desc.isWritable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ bool ProxyObject::deleteOwnProperty(ExecutionState& state, const ObjectPropertyN
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -233,11 +233,11 @@ bool ProxyObject::deleteOwnProperty(ExecutionState& state, const ObjectPropertyN
|
|||
|
||||
// 15. If targetDesc.[[Configurable]] is false, throw a TypeError exception.
|
||||
if (!targetDesc.isConfigurable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
if (!target.asObject()->isExtensible(state)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -248,7 +248,7 @@ ObjectGetResult ProxyObject::getOwnProperty(ExecutionState& state, const ObjectP
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ ObjectGetResult ProxyObject::getOwnProperty(ExecutionState& state, const ObjectP
|
|||
|
||||
// 11. If Type(trapResultObj) is neither Object nor Undefined, throw a TypeError exception.
|
||||
if (!trapResultObj.isObject() && !trapResultObj.isUndefined()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ ObjectGetResult ProxyObject::getOwnProperty(ExecutionState& state, const ObjectP
|
|||
}
|
||||
// b. If targetDesc.[[Configurable]] is false, throw a TypeError exception.
|
||||
if (!targetDesc.isConfigurable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
// c. Let extensibleTarget be IsExtensible(target).
|
||||
|
|
@ -304,7 +304,7 @@ ObjectGetResult ProxyObject::getOwnProperty(ExecutionState& state, const ObjectP
|
|||
bool extensibleTarget = target.asObject()->isExtensible(state);
|
||||
// f. If extensibleTarget is false, throw a TypeError exception.
|
||||
if (!extensibleTarget) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
// g. Return undefined.
|
||||
|
|
@ -346,7 +346,7 @@ bool ProxyObject::preventExtensions(ExecutionState& state)
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 2. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ bool ProxyObject::preventExtensions(ExecutionState& state)
|
|||
bool targetIsExtensible = target.asObject()->isExtensible(state);
|
||||
// c. If targetIsExtensible is true, throw a TypeError exception.
|
||||
if (targetIsExtensible) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -399,7 +399,7 @@ ObjectHasPropertyResult ProxyObject::hasProperty(ExecutionState& state, const Ob
|
|||
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return ObjectHasPropertyResult();
|
||||
}
|
||||
|
||||
|
|
@ -446,14 +446,14 @@ ObjectHasPropertyResult ProxyObject::hasProperty(ExecutionState& state, const Ob
|
|||
if (targetDesc.hasValue()) {
|
||||
// i. If targetDesc.[[Configurable]] is false, throw a TypeError exception.
|
||||
if (!targetDesc.isConfigurable()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
// ii. Let extensibleTarget be IsExtensible(target).
|
||||
bool extensibleTarget = target.asObject()->isExtensible(state);
|
||||
// iv. If extensibleTarget is false, throw a TypeError exception.
|
||||
if (!extensibleTarget) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -478,7 +478,7 @@ Object::OwnPropertyKeyVector ProxyObject::ownPropertyKeys(ExecutionState& state)
|
|||
// 1. Let handler be the value of the [[ProxyHandler]] internal slot of O.
|
||||
// 2. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return OwnPropertyKeyVector();
|
||||
}
|
||||
Value handler(this->handler());
|
||||
|
|
@ -512,7 +512,7 @@ Object::OwnPropertyKeyVector ProxyObject::ownPropertyKeys(ExecutionState& state)
|
|||
for (size_t i = 0; i < trapResult.size(); i++) {
|
||||
for (size_t j = i + 1; j < trapResult.size(); j++) {
|
||||
if (trapResult[i].equalsTo(state, trapResult[j])) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s Contains duplacted entries.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s Contains duplacted entries.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -576,7 +576,7 @@ Object::OwnPropertyKeyVector ProxyObject::ownPropertyKeys(ExecutionState& state)
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: the key of targetNonconfigurableKeys is not an element of uncheckedResultKeys.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: the key of targetNonconfigurableKeys is not an element of uncheckedResultKeys.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -599,12 +599,12 @@ Object::OwnPropertyKeyVector ProxyObject::ownPropertyKeys(ExecutionState& state)
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: the key of targetConfigurableKeys is not an element of uncheckedResultKeys.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: the key of targetConfigurableKeys is not an element of uncheckedResultKeys.");
|
||||
}
|
||||
}
|
||||
// 24. If uncheckedResultKeys is not empty, throw a TypeError exception.
|
||||
if (uncheckedResultKeys.size()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: uncheckedResultKeys is not empty");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: uncheckedResultKeys is not empty");
|
||||
}
|
||||
|
||||
// 25. Return trapResult.
|
||||
|
|
@ -618,7 +618,7 @@ bool ProxyObject::isExtensible(ExecutionState& state)
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 2. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -653,7 +653,7 @@ bool ProxyObject::isExtensible(ExecutionState& state)
|
|||
|
||||
// 12. If SameValue(booleanTrapResult, targetResult) is false, throw a TypeError exception.
|
||||
if (targetResult != booleanTrapResult) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
// 13. Return booleanTrapResult.
|
||||
|
|
@ -678,7 +678,7 @@ bool ProxyObject::setPrototype(ExecutionState& state, const Value& value)
|
|||
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -726,7 +726,7 @@ bool ProxyObject::setPrototype(ExecutionState& state, const Value& value)
|
|||
|
||||
// 16. If booleanTrapResult is true and SameValue(V, targetProto) is false, throw a TypeError exception.
|
||||
if (booleanTrapResult && value != targetProto) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -754,7 +754,7 @@ Value ProxyObject::getPrototype(ExecutionState& state)
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 2. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
@ -786,7 +786,7 @@ Value ProxyObject::getPrototype(ExecutionState& state)
|
|||
|
||||
// 10. If Type(handlerProto) is neither Object nor Null, throw a TypeError exception.
|
||||
if (!handlerProto.isObject() && !handlerProto.isNull()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
@ -803,7 +803,7 @@ Value ProxyObject::getPrototype(ExecutionState& state)
|
|||
|
||||
// 16. If SameValue(handlerProto, targetProto) is false, throw a TypeError exception.
|
||||
if (handlerProto != targetProto) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
@ -819,7 +819,7 @@ ObjectGetResult ProxyObject::get(ExecutionState& state, const ObjectPropertyName
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
|
||||
|
|
@ -858,7 +858,7 @@ ObjectGetResult ProxyObject::get(ExecutionState& state, const ObjectPropertyName
|
|||
if (targetDesc.isDataProperty() && !targetDesc.isConfigurable() && !targetDesc.isWritable()) {
|
||||
// i. If SameValue(trapResult, targetDesc.[[Value]]) is false, throw a TypeError exception.
|
||||
if (trapResult != targetDesc.value(state, target)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error.");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -866,7 +866,7 @@ ObjectGetResult ProxyObject::get(ExecutionState& state, const ObjectPropertyName
|
|||
if (!targetDesc.isDataProperty() && !targetDesc.isConfigurable() && (!targetDesc.jsGetterSetter()->hasGetter() || targetDesc.jsGetterSetter()->getter().isUndefined())) {
|
||||
// i. If trapResult is not undefined, throw a TypeError exception.
|
||||
if (!trapResult.isUndefined()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error.");
|
||||
return ObjectGetResult();
|
||||
}
|
||||
}
|
||||
|
|
@ -884,7 +884,7 @@ bool ProxyObject::set(ExecutionState& state, const ObjectPropertyName& propertyN
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 3. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -928,7 +928,7 @@ bool ProxyObject::set(ExecutionState& state, const ObjectPropertyName& propertyN
|
|||
if (targetDesc.isDataProperty() && !targetDesc.isConfigurable() && !targetDesc.isWritable()) {
|
||||
// i. If SameValue(V, targetDesc.[[Value]]) is false, throw a TypeError exception.
|
||||
if (v != targetDesc.value(state, target)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -936,7 +936,7 @@ bool ProxyObject::set(ExecutionState& state, const ObjectPropertyName& propertyN
|
|||
if (!targetDesc.isDataProperty() && !targetDesc.isConfigurable()) {
|
||||
// i. If targetDesc.[[Set]] is undefined, throw a TypeError exception.
|
||||
if ((!targetDesc.jsGetterSetter()->hasSetter() || targetDesc.jsGetterSetter()->setter().isUndefined())) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy Type Error.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy Type Error.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -958,7 +958,7 @@ Value ProxyObject::call(ExecutionState& state, const Value& receiver, const size
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 2. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
@ -998,7 +998,7 @@ Value ProxyObject::construct(ExecutionState& state, const size_t argc, Value* ar
|
|||
auto strings = &state.context()->staticStrings();
|
||||
// 2. If handler is null, throw a TypeError exception.
|
||||
if (this->handler() == nullptr) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: Proxy handler should not be null.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: Proxy handler should not be null.");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
@ -1033,7 +1033,7 @@ Value ProxyObject::construct(ExecutionState& state, const size_t argc, Value* ar
|
|||
|
||||
// 11. If Type(newObj) is not Object, throw a TypeError exception.
|
||||
if (!newObj.isObject()) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString, "%s: The result of [[Construct]] must be an Object.");
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::TypeError, strings->Proxy.string(), false, String::emptyString(), "%s: The result of [[Construct]] must be an Object.");
|
||||
return Value();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ RegExpObject::RegExpObject(ExecutionState& state, Object* proto, String* source,
|
|||
: RegExpObject(state, proto, true)
|
||||
{
|
||||
internalInit(state, source, (Option)option);
|
||||
m_optionString = String::emptyString;
|
||||
m_optionString = String::emptyString();
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(ExecutionState& state, Object* proto, bool hasLastIndex)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ public:
|
|||
RegExpObject(ExecutionState& state, String* source, unsigned int option);
|
||||
RegExpObject(ExecutionState& state, Object* proto, String* source, unsigned int option);
|
||||
|
||||
void init(ExecutionState& state, String* source, String* option = String::emptyString);
|
||||
void init(ExecutionState& state, String* source, String* option = String::emptyString());
|
||||
|
||||
uint64_t computedLastIndex(ExecutionState& state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class RopeString : public String {
|
|||
RopeString()
|
||||
: String()
|
||||
{
|
||||
m_left = String::emptyString;
|
||||
m_left = String::emptyString();
|
||||
m_bufferData.has8BitContent = true;
|
||||
m_bufferData.hasSpecialImpl = true;
|
||||
m_bufferData.length = 0;
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ bool SandBox::createStackTrace(StackTraceDataOnStackVector& stackTraceDataVector
|
|||
builder.appendString("[native function]");
|
||||
builder.appendString(" } ");
|
||||
data.srcName = builder.finalize();
|
||||
data.sourceCode = String::emptyString;
|
||||
data.sourceCode = String::emptyString();
|
||||
|
||||
data.functionName = cb->functionName().string();
|
||||
data.isEval = false;
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ struct StackTraceDataOnStack : public gc {
|
|||
bool isEval;
|
||||
|
||||
StackTraceDataOnStack()
|
||||
: srcName(String::emptyString)
|
||||
, sourceCode(String::emptyString)
|
||||
: srcName(String::emptyString())
|
||||
, sourceCode(String::emptyString())
|
||||
, loc(SIZE_MAX, SIZE_MAX, SIZE_MAX)
|
||||
, functionName(String::emptyString)
|
||||
, functionName(String::emptyString())
|
||||
#ifdef ESCARGOT_DEBUGGER
|
||||
, executionStateDepth(0)
|
||||
#endif /* ESCARGOT_DEBUGGER */
|
||||
|
|
|
|||
|
|
@ -90,14 +90,14 @@ SharedArrayBufferObject* SharedArrayBufferObject::allocateSharedArrayBuffer(Exec
|
|||
});
|
||||
|
||||
if (UNLIKELY(byteLength >= ArrayBuffer::maxArrayBufferSize)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
}
|
||||
|
||||
if (UNLIKELY(maxByteLength.hasValue())) {
|
||||
ASSERT(byteLength <= maxByteLength.value());
|
||||
uint64_t maxLength = maxByteLength.value();
|
||||
if (UNLIKELY(maxLength >= ArrayBuffer::maxArrayBufferSize)) {
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().SharedArrayBuffer.string(), false, String::emptyString(), ErrorObject::Messages::GlobalObject_InvalidArrayBufferSize);
|
||||
}
|
||||
|
||||
return new SharedArrayBufferObject(state, proto, byteLength, maxLength);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Escargot {
|
|||
void StaticStrings::initStaticStrings()
|
||||
{
|
||||
AtomicStringMap* atomicStringMap = m_atomicStringMap;
|
||||
atomicStringMap->insert(String::emptyString);
|
||||
atomicStringMap->insert(String::emptyString());
|
||||
|
||||
#define INIT_STATIC_STRING(name) name.initStaticString(atomicStringMap, new ASCIIStringFromExternalMemory(#name, sizeof(#name) - 1));
|
||||
FOR_EACH_STATIC_STRING(INIT_STATIC_STRING)
|
||||
|
|
@ -178,7 +178,7 @@ void StaticStrings::initStaticStrings()
|
|||
#define DECLARE_LAZY_STATIC_STRING(Name, stringContent) \
|
||||
AtomicString StaticStrings::lazy##Name() \
|
||||
{ \
|
||||
if (UNLIKELY(m_lazy##Name.string() == String::emptyString)) { \
|
||||
if (UNLIKELY(m_lazy##Name.string() == String::emptyString())) { \
|
||||
m_lazy##Name = AtomicString(m_atomicStringMap, stringContent, sizeof(stringContent) - 1, AtomicString::FromExternalMemory); \
|
||||
} \
|
||||
return m_lazy##Name; \
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
#include "bignum-dtoa.h"
|
||||
|
||||
namespace Escargot {
|
||||
MAY_THREAD_LOCAL String* String::emptyString;
|
||||
MAY_THREAD_LOCAL String* String::emptyStringInstance;
|
||||
|
||||
std::vector<std::string> split(const std::string& s, char seperator)
|
||||
{
|
||||
|
|
@ -637,14 +637,14 @@ ASCIIStringDataNonGCStd dtoa(double number)
|
|||
|
||||
void String::initEmptyString()
|
||||
{
|
||||
ASSERT(!String::emptyString);
|
||||
ASSERT(!String::emptyString());
|
||||
String* emptyStr = new (NoGC) ASCIIStringFromExternalMemory("");
|
||||
// mark empty string as AtomicString source
|
||||
// because empty string is the default string value of empty AtomicString
|
||||
emptyStr->m_typeTag = (size_t)POINTER_VALUE_STRING_TAG_IN_DATA | (size_t)emptyStr;
|
||||
|
||||
ASSERT(emptyStr->isAtomicStringSource());
|
||||
String::emptyString = emptyStr;
|
||||
String::emptyStringInstance = emptyStr;
|
||||
}
|
||||
|
||||
#define LATIN1_LARGE_INLINE_BUFFER(F) \
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#define __EscargotString__
|
||||
|
||||
#include "runtime/PointerValue.h"
|
||||
#include "runtime/ThreadLocal.h"
|
||||
#include "util/BasicString.h"
|
||||
#include "util/Vector.h"
|
||||
#include <string>
|
||||
|
|
@ -229,6 +230,7 @@ struct StringBufferAccessData {
|
|||
|
||||
class String : public PointerValue {
|
||||
friend class AtomicString;
|
||||
friend class ThreadLocal;
|
||||
|
||||
protected:
|
||||
String()
|
||||
|
|
@ -341,9 +343,17 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
// initialize String::emptyString value
|
||||
// initialize String::emptyString() value
|
||||
// its called only once by VMInstance constructor
|
||||
static void initEmptyString();
|
||||
static String* emptyString()
|
||||
{
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
return ThreadLocal::emptyString();
|
||||
#else
|
||||
return String::emptyStringInstance;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <const size_t srcLen>
|
||||
static String* fromASCII(const char (&src)[srcLen])
|
||||
|
|
@ -525,8 +535,6 @@ public:
|
|||
return bufferAccessData().toUTF8String<UTF8StringDataNonGCStd>();
|
||||
}
|
||||
|
||||
static MAY_THREAD_LOCAL String* emptyString;
|
||||
|
||||
uint64_t tryToUseAsIndex() const;
|
||||
uint32_t tryToUseAsIndex32() const;
|
||||
uint32_t tryToUseAsIndexProperty() const;
|
||||
|
|
@ -579,6 +587,8 @@ public:
|
|||
String* trim(StringTrimWhere where = StringTrimWhere::TrimBoth);
|
||||
|
||||
private:
|
||||
static MAY_THREAD_LOCAL String* emptyStringInstance;
|
||||
|
||||
size_t m_typeTag;
|
||||
|
||||
protected:
|
||||
|
|
@ -1076,7 +1086,7 @@ public:
|
|||
if (iter != end()) {
|
||||
return iter->second;
|
||||
}
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
void* operator new(size_t size) = delete;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ String* StringBuilderBase::finalizeBase(StringBuilderPiece* piecesInlineStorage,
|
|||
auto length = contentLength();
|
||||
if (!length) {
|
||||
clear();
|
||||
return String::emptyString;
|
||||
return String::emptyString();
|
||||
}
|
||||
|
||||
checkStringLengthLimit(state, length);
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ public:
|
|||
m_has8BitContent = true;
|
||||
m_internalStorageContentLength = 0;
|
||||
m_piecesInlineStorageUsage = 0;
|
||||
m_processedString = String::emptyString;
|
||||
m_processedString = String::emptyString();
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
clearInternal();
|
||||
m_processedString = String::emptyString;
|
||||
m_processedString = String::emptyString();
|
||||
}
|
||||
|
||||
struct StringBuilderPiece {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ namespace Escargot {
|
|||
|
||||
class StringObject : public DerivedObject {
|
||||
public:
|
||||
StringObject(ExecutionState& state, String* value = String::emptyString);
|
||||
StringObject(ExecutionState& state, Object* proto, String* value = String::emptyString);
|
||||
StringObject(ExecutionState& state, String* value = String::emptyString());
|
||||
StringObject(ExecutionState& state, Object* proto, String* value = String::emptyString());
|
||||
|
||||
String* primitiveValue()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public:
|
|||
ALWAYS_INLINE StringView()
|
||||
: String()
|
||||
{
|
||||
initBufferAccessData(String::emptyString, 0, 0);
|
||||
initBufferAccessData(String::emptyString(), 0, 0);
|
||||
}
|
||||
|
||||
size_t start() const
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Escargot {
|
|||
|
||||
String* Symbol::descriptionString() const
|
||||
{
|
||||
return m_description ? const_cast<String*>(m_description.value()) : String::emptyString;
|
||||
return m_description ? const_cast<String*>(m_description.value()) : String::emptyString();
|
||||
}
|
||||
|
||||
Value Symbol::descriptionValue() const
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ namespace Escargot {
|
|||
|
||||
MAY_THREAD_LOCAL bool ThreadLocal::inited;
|
||||
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
size_t ThreadLocal::g_stackLimitTlsOffset;
|
||||
size_t ThreadLocal::g_emptyStringTlsOffset;
|
||||
#endif
|
||||
|
||||
MAY_THREAD_LOCAL size_t ThreadLocal::g_stackLimit;
|
||||
MAY_THREAD_LOCAL std::mt19937* ThreadLocal::g_randEngine;
|
||||
MAY_THREAD_LOCAL bf_context_t ThreadLocal::g_bfContext;
|
||||
|
|
@ -139,6 +144,25 @@ void ThreadLocal::initialize()
|
|||
// initialize should be invoked only once in each thread
|
||||
RELEASE_ASSERT(!inited);
|
||||
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
auto tlsBase = tlsBaseAddress();
|
||||
if (!g_stackLimitTlsOffset) {
|
||||
g_stackLimitTlsOffset = reinterpret_cast<char*>(&g_stackLimit) - tlsBase;
|
||||
} else {
|
||||
// runtime check
|
||||
size_t newDistance = reinterpret_cast<char*>(&g_stackLimit) - tlsBase;
|
||||
RELEASE_ASSERT(newDistance == g_stackLimitTlsOffset);
|
||||
}
|
||||
|
||||
if (!g_emptyStringTlsOffset) {
|
||||
g_emptyStringTlsOffset = reinterpret_cast<char*>(&String::emptyStringInstance) - tlsBase;
|
||||
} else {
|
||||
// runtime check
|
||||
size_t newDistance = reinterpret_cast<char*>(&String::emptyStringInstance) - tlsBase;
|
||||
RELEASE_ASSERT(newDistance == g_emptyStringTlsOffset);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Heap is initialized for each thread
|
||||
Heap::initialize();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct WASMContext {
|
|||
namespace Escargot {
|
||||
|
||||
class ASTAllocator;
|
||||
class String;
|
||||
|
||||
class GCEventListenerSet {
|
||||
public:
|
||||
|
|
@ -89,6 +90,10 @@ private:
|
|||
class ThreadLocal {
|
||||
friend class StackOverflowDisabler;
|
||||
static MAY_THREAD_LOCAL bool inited;
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
static size_t g_stackLimitTlsOffset;
|
||||
static size_t g_emptyStringTlsOffset;
|
||||
#endif
|
||||
|
||||
// Global data per thread
|
||||
static MAY_THREAD_LOCAL size_t g_stackLimit;
|
||||
|
|
@ -103,6 +108,49 @@ class ThreadLocal {
|
|||
// custom data allocated by user through Platform::allocateThreadLocalCustomData
|
||||
static MAY_THREAD_LOCAL void* g_customData;
|
||||
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
static ALWAYS_INLINE char* tlsBaseAddress()
|
||||
{
|
||||
#if defined(CPU_X86_64)
|
||||
char* fs;
|
||||
asm inline("mov %%fs:0, %0"
|
||||
: "=r"(fs));
|
||||
return fs;
|
||||
#elif defined(CPU_X86)
|
||||
char* gs;
|
||||
asm inline("mov %%gs:0, %0"
|
||||
: "=r"(gs));
|
||||
return gs;
|
||||
#elif defined(CPU_ARM32) || defined(CPU_ARM64)
|
||||
return reinterpret_cast<char*>(__builtin_thread_pointer());
|
||||
#endif
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE char* tlsValueAddress(size_t offset)
|
||||
{
|
||||
return tlsBaseAddress() + offset;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE size_t readTlsValue(size_t offset)
|
||||
{
|
||||
#if defined(CPU_X86_64)
|
||||
size_t value;
|
||||
asm inline("mov %%fs:(%1), %0"
|
||||
: "=r"(value)
|
||||
: "r"(offset));
|
||||
return value;
|
||||
#elif defined(CPU_X86)
|
||||
size_t value;
|
||||
asm inline("mov %%gs:(%1), %0"
|
||||
: "=r"(value)
|
||||
: "r"(offset));
|
||||
return value;
|
||||
#elif defined(CPU_ARM32) || defined(CPU_ARM64)
|
||||
return *(reinterpret_cast<size_t*>(tlsBaseAddress() + offset));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
static void initialize();
|
||||
static void finalize();
|
||||
|
|
@ -111,11 +159,23 @@ public:
|
|||
return inited;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
static ALWAYS_INLINE String* emptyString()
|
||||
{
|
||||
return reinterpret_cast<String*>(readTlsValue(g_emptyStringTlsOffset));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Global data getter
|
||||
static size_t stackLimit()
|
||||
static ALWAYS_INLINE size_t stackLimit()
|
||||
{
|
||||
ASSERT(inited);
|
||||
#if defined(ENABLE_TLS_ACCESS_BY_ADDRESS)
|
||||
ASSERT(g_stackLimit == readTlsValue(g_stackLimitTlsOffset));
|
||||
return readTlsValue(g_stackLimitTlsOffset);
|
||||
#else
|
||||
return g_stackLimit;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Use this limit if you want to use more stack
|
||||
|
|
|
|||
|
|
@ -379,9 +379,9 @@ VMInstance::VMInstance(const char* locale, const char* timezone, const char* bas
|
|||
},
|
||||
nullptr, nullptr, nullptr);
|
||||
|
||||
if (!String::emptyString) {
|
||||
if (!String::emptyString()) {
|
||||
String::initEmptyString();
|
||||
ASSERT(!!String::emptyString && String::emptyString->isAtomicStringSource());
|
||||
ASSERT(!!String::emptyString() && String::emptyString()->isAtomicStringSource());
|
||||
}
|
||||
m_staticStrings.initStaticStrings();
|
||||
|
||||
|
|
|
|||
|
|
@ -905,7 +905,7 @@ static Value builtinWASMGlobalValueSetter(ExecutionState& state, Value thisValue
|
|||
Object* proto = Object::getPrototypeFromConstructor(state, newTarget.value(), [](ExecutionState& state, Context* constructorRealm) -> Object* { \
|
||||
return constructorRealm->globalObject()->lowerCaseErrorName##ErrorPrototype(); \
|
||||
}); \
|
||||
ErrorObject* obj = new errorName##ErrorObject(state, proto, String::emptyString); \
|
||||
ErrorObject* obj = new errorName##ErrorObject(state, proto, String::emptyString()); \
|
||||
Value message = argv[0]; \
|
||||
if (!message.isUndefined()) { \
|
||||
obj->defineOwnPropertyThrowsException(state, state.context()->staticStrings().message, \
|
||||
|
|
@ -1106,7 +1106,7 @@ void GlobalObject::installWebAssembly(ExecutionState& state)
|
|||
m_##errorname##ErrorPrototype = new Object(state, m_errorPrototype); \
|
||||
m_##errorname##ErrorPrototype->setGlobalIntrinsicObject(state, true); \
|
||||
m_##errorname##ErrorPrototype->defineOwnProperty(state, state.context()->staticStrings().constructor, ObjectPropertyDescriptor(errorname##Error, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##ErrorPrototype->defineOwnProperty(state, state.context()->staticStrings().message, ObjectPropertyDescriptor(String::emptyString, (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##ErrorPrototype->defineOwnProperty(state, state.context()->staticStrings().message, ObjectPropertyDescriptor(String::emptyString(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
m_##errorname##ErrorPrototype->defineOwnProperty(state, state.context()->staticStrings().name, ObjectPropertyDescriptor(state.context()->staticStrings().bname##Error.string(), (ObjectPropertyDescriptor::PresentAttribute)(ObjectPropertyDescriptor::WritablePresent | ObjectStructurePropertyDescriptor::ConfigurablePresent))); \
|
||||
errorname##Error->setFunctionPrototype(state, m_##errorname##ErrorPrototype); \
|
||||
wasm->defineOwnProperty(state, ObjectPropertyName(state.context()->staticStrings().bname##Error), \
|
||||
|
|
|
|||
2
third_party/GCutil
vendored
2
third_party/GCutil
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 7de13bc70b364b466037a3bc5d56b6e5546df7d5
|
||||
Subproject commit 4e50abb83f351bcc1760b0e958aade44e838ba9c
|
||||
2
third_party/yarr/WTFString.h
vendored
2
third_party/yarr/WTFString.h
vendored
|
|
@ -35,7 +35,7 @@ class String {
|
|||
public:
|
||||
String()
|
||||
: m_impl()
|
||||
, m_implBufferAccessData(Escargot::String::emptyString->bufferAccessData())
|
||||
, m_implBufferAccessData(Escargot::String::emptyString()->bufferAccessData())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue