Skip to content

Commit

Permalink
Remove unused parameter in toBoolean method
Browse files Browse the repository at this point in the history
Signed-off-by: HyukWoo Park <[email protected]>
  • Loading branch information
clover2123 committed Oct 18, 2023
1 parent 463d730 commit f0ddc35
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 69 deletions.
2 changes: 1 addition & 1 deletion build/android/escargot/src/main/cpp/escargot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ Java_com_samsung_lwe_escargot_JavaScriptValue_toBoolean(JNIEnv* env, jobject thi
ValueRef* thisValueRef = unwrapValueRefFromValue(env, env->GetObjectClass(thiz), thiz);

auto evaluatorResult = Evaluator::execute(contextRef->get(), [](ExecutionStateRef* state, ValueRef* thisValueRef) -> ValueRef* {
return ValueRef::create(thisValueRef->toBoolean(state));
return ValueRef::create(thisValueRef->toBoolean());
}, thisValueRef);

return createOptionalValueFromEvaluatorBooleanResult(env, context, contextRef->get(),
Expand Down
6 changes: 3 additions & 3 deletions src/api/EscargotPublic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3396,9 +3396,9 @@ ValueRef* ValueRef::createUndefined()
.payload());
}

bool ValueRef::toBoolean(ExecutionStateRef* es)
bool ValueRef::toBoolean()
{
return toImpl(this).toBoolean(*toImpl(es));
return toImpl(this).toBoolean();
}

double ValueRef::toNumber(ExecutionStateRef* es)
Expand Down Expand Up @@ -3694,7 +3694,7 @@ BooleanObjectRef* BooleanObjectRef::create(ExecutionStateRef* state)

void BooleanObjectRef::setPrimitiveValue(ExecutionStateRef* state, ValueRef* str)
{
toImpl(this)->setPrimitiveValue(*toImpl(state), toImpl(str).toBoolean(*toImpl(state)));
toImpl(this)->setPrimitiveValue(*toImpl(state), toImpl(str).toBoolean());
}

bool BooleanObjectRef::primitiveValue()
Expand Down
2 changes: 1 addition & 1 deletion src/api/EscargotPublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ class ESCARGOT_EXPORT ValueRef {
ESCARGOT_TYPEDARRAY_REF_LIST(DEFINE_VALUEREF_IS_AS);
#undef DEFINE_VALUEREF_IS_AS

bool toBoolean(ExecutionStateRef* state);
bool toBoolean();
double toNumber(ExecutionStateRef* state);
double toInteger(ExecutionStateRef* state);
double toLength(ExecutionStateRef* state);
Expand Down
14 changes: 7 additions & 7 deletions src/builtins/BuiltinArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ static Value builtinArrayEvery(ExecutionState& state, Value thisValue, size_t ar
Value args[] = { kValue, Value(k), O };
Value testResult = Object::call(state, callbackfn, T, 3, args);

if (!testResult.toBoolean(state)) {
if (!testResult.toBoolean()) {
return Value(false);
}

Expand Down Expand Up @@ -1079,7 +1079,7 @@ static Value builtinArrayFilter(ExecutionState& state, Value thisValue, size_t a
Value selected = Object::call(state, callbackfn, T, 3, v);

// If ToBoolean(selected) is true, then
if (selected.toBoolean(state)) {
if (selected.toBoolean()) {
// Let status be CreateDataPropertyOrThrow (A, ToString(to), kValue).
ASSERT(A != nullptr);
A->defineOwnPropertyThrowsException(state, ObjectPropertyName(state, Value(to)), ObjectPropertyDescriptor(kValue, ObjectPropertyDescriptor::AllPresent));
Expand Down Expand Up @@ -1188,7 +1188,7 @@ static Value builtinArraySome(ExecutionState& state, Value thisValue, size_t arg
Value argv[] = { kValue, Value(k), O };
Value testResult = Object::call(state, callbackfn, T, 3, argv);
// If ToBoolean(testResult) is true, return true.
if (testResult.toBoolean(state)) {
if (testResult.toBoolean()) {
return Value(true);
}
} else {
Expand Down Expand Up @@ -1699,7 +1699,7 @@ static Value builtinArrayFind(ExecutionState& state, Value thisValue, size_t arg
Value kValue = O->get(state, ObjectPropertyName(state, Value(k))).value(state, O);
// Let testResult be ToBoolean(? Call(predicate, thisArg, « kValue, k, O »)).
Value v[] = { kValue, Value(k), O };
bool testResult = Object::call(state, argv[0], thisArg, 3, v).toBoolean(state);
bool testResult = Object::call(state, argv[0], thisArg, 3, v).toBoolean();
// If testResult is true, return kValue.
if (testResult) {
return kValue;
Expand Down Expand Up @@ -1734,7 +1734,7 @@ static Value builtinArrayFindIndex(ExecutionState& state, Value thisValue, size_
Value kValue = O->get(state, ObjectPropertyName(state, Value(k))).value(state, O);
// Let testResult be ToBoolean(? Call(predicate, thisArg, « kValue, k, O »)).
Value v[] = { kValue, Value(k), O };
bool testResult = Object::call(state, argv[0], thisArg, 3, v).toBoolean(state);
bool testResult = Object::call(state, argv[0], thisArg, 3, v).toBoolean();
// If testResult is true, return k.
if (testResult) {
return Value(k);
Expand Down Expand Up @@ -1874,7 +1874,7 @@ static Value builtinArrayFindLast(ExecutionState& state, Value thisValue, size_t
Value predicateArgv[] = {
kValue, Value(k), Value(O)
};
bool testResult = Object::call(state, predicate, thisArg, 3, predicateArgv).toBoolean(state);
bool testResult = Object::call(state, predicate, thisArg, 3, predicateArgv).toBoolean();
// d. If testResult is true, return kValue.
if (testResult) {
return kValue;
Expand Down Expand Up @@ -1910,7 +1910,7 @@ static Value builtinArrayFindLastIndex(ExecutionState& state, Value thisValue, s
Value predicateArgv[] = {
kValue, Value(k), Value(O)
};
bool testResult = Object::call(state, predicate, thisArg, 3, predicateArgv).toBoolean(state);
bool testResult = Object::call(state, predicate, thisArg, 3, predicateArgv).toBoolean();
// d. If testResult is true, return kValue.
if (testResult) {
return Value(k);
Expand Down
2 changes: 1 addition & 1 deletion src/builtins/BuiltinBoolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace Escargot {

static Value builtinBooleanConstructor(ExecutionState& state, Value thisValue, size_t argc, Value* argv, Optional<Object*> newTarget)
{
bool primitiveVal = argv[0].toBoolean(state);
bool primitiveVal = argv[0].toBoolean();
if (!newTarget.hasValue()) {
return Value(primitiveVal);
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/builtins/BuiltinRegExp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ static Value builtinRegExpReplace(ExecutionState& state, Value thisValue, size_t
if (!functionalReplace) {
replaceValue = replaceValue.toString(state);
}
bool global = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().global)).value(state, rx).toBoolean(state);
bool global = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().global)).value(state, rx).toBoolean();
if (global) {
fullUnicode = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().unicode)).value(state, rx).toBoolean(state);
fullUnicode = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().unicode)).value(state, rx).toBoolean();
rx.asObject()->setThrowsException(state, ObjectPropertyName(state, state.context()->staticStrings().lastIndex), Value(0), rx);
}
ValueVectorWithInlineStorage results;
Expand Down Expand Up @@ -509,13 +509,13 @@ static Value builtinRegExpMatch(ExecutionState& state, Value thisValue, size_t a
ASSERT(str != nullptr);

//21.2.5.6.8
bool global = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().global)).value(state, rx).toBoolean(state);
bool global = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().global)).value(state, rx).toBoolean();

if (!global) {
return regExpExec(state, rx.asObject(), str);
}

bool fullUnicode = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().unicode)).value(state, rx).toBoolean(state);
bool fullUnicode = rx.asObject()->get(state, ObjectPropertyName(state, state.context()->staticStrings().unicode)).value(state, rx).toBoolean();
rx.asObject()->setThrowsException(state, ObjectPropertyName(state, state.context()->staticStrings().lastIndex), Value(0), rx);
ArrayObject* A = new ArrayObject(state);
size_t n = 0;
Expand Down
14 changes: 7 additions & 7 deletions src/builtins/BuiltinTypedArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ static Value builtinTypedArraySome(ExecutionState& state, Value thisValue, size_
Value testResult = Object::call(state, callbackfn, T, 3, args);

// If ToBoolean(testResult) is true, return true.
if (testResult.toBoolean(state)) {
if (testResult.toBoolean()) {
return Value(true);
}

Expand Down Expand Up @@ -1002,7 +1002,7 @@ static Value builtinTypedArrayEvery(ExecutionState& state, Value thisValue, size
Value args[] = { kValue, Value(k), O };
Value testResult = Object::call(state, callbackfn, T, 3, args);

if (!testResult.toBoolean(state)) {
if (!testResult.toBoolean()) {
return Value(false);
}

Expand Down Expand Up @@ -1091,7 +1091,7 @@ static Value builtinTypedArrayFilter(ExecutionState& state, Value thisValue, siz
while (k < len) {
Value kValue = O->getIndexedProperty(state, Value(k)).value(state, O);
Value args[] = { kValue, Value(k), O };
bool selected = Object::call(state, callbackfn, T, 3, args).toBoolean(state);
bool selected = Object::call(state, callbackfn, T, 3, args).toBoolean();
if (selected) {
kept.push_back(kValue);
captured++;
Expand Down Expand Up @@ -1140,7 +1140,7 @@ static Value builtinTypedArrayFind(ExecutionState& state, Value thisValue, size_
Value kValue = O->getIndexedProperty(state, Value(k)).value(state, O);
// Let testResult be ToBoolean(Call(predicate, thisArg, «kValue, k, O»)).
Value args[] = { kValue, Value(k), O };
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean(state);
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean();
// If testResult is true, return kValue.
if (testResult) {
return kValue;
Expand Down Expand Up @@ -1179,7 +1179,7 @@ static Value builtinTypedArrayFindIndex(ExecutionState& state, Value thisValue,
Value kValue = O->getIndexedProperty(state, Value(k)).value(state, O);
// Let testResult be ToBoolean(? Call(predicate, thisArg, « kValue, k, O »)).
Value args[] = { kValue, Value(k), O };
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean(state);
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean();
// If testResult is true, return k.
if (testResult) {
return Value(k);
Expand Down Expand Up @@ -1217,7 +1217,7 @@ static Value builtinTypedArrayFindLast(ExecutionState& state, Value thisValue, s
kValue = O->getIndexedProperty(state, Value(k)).value(state, O);
// Let testResult be ToBoolean(Call(predicate, thisArg, «kValue, k, O»)).
Value args[] = { kValue, Value(k), O };
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean(state);
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean();
// If testResult is true, return kValue.
if (testResult) {
return kValue;
Expand Down Expand Up @@ -1255,7 +1255,7 @@ static Value builtinTypedArrayFindLastIndex(ExecutionState& state, Value thisVal
Value kValue = O->getIndexedProperty(state, Value(k)).value(state, O);
// Let testResult be ToBoolean(? Call(predicate, thisArg, « kValue, k, O »)).
Value args[] = { kValue, Value(k), O };
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean(state);
bool testResult = Object::call(state, predicate, thisArg, 3, args).toBoolean();
// If testResult is true, return k.
if (testResult) {
return Value(k);
Expand Down
10 changes: 5 additions & 5 deletions src/interpreter/ByteCodeInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Value Interpreter::interpret(ExecutionState* state, ByteCodeBlock* byteCodeBlock
{
UnaryNot* code = (UnaryNot*)programCounter;
const Value& val = registerFile[code->m_srcIndex];
registerFile[code->m_dstIndex] = Value(!val.toBoolean(*state));
registerFile[code->m_dstIndex] = Value(!val.toBoolean());
ADD_PROGRAM_COUNTER(UnaryNot);
NEXT_INSTRUCTION();
}
Expand Down Expand Up @@ -692,7 +692,7 @@ Value Interpreter::interpret(ExecutionState* state, ByteCodeBlock* byteCodeBlock
{
JumpIfTrue* code = (JumpIfTrue*)programCounter;
ASSERT(code->m_jumpPosition != SIZE_MAX);
if (registerFile[code->m_registerIndex].toBoolean(*state)) {
if (registerFile[code->m_registerIndex].toBoolean()) {
programCounter = code->m_jumpPosition;
} else {
ADD_PROGRAM_COUNTER(JumpIfTrue);
Expand Down Expand Up @@ -720,7 +720,7 @@ Value Interpreter::interpret(ExecutionState* state, ByteCodeBlock* byteCodeBlock
{
JumpIfFalse* code = (JumpIfFalse*)programCounter;
ASSERT(code->m_jumpPosition != SIZE_MAX);
if (!registerFile[code->m_registerIndex].toBoolean(*state)) {
if (!registerFile[code->m_registerIndex].toBoolean()) {
programCounter = code->m_jumpPosition;
} else {
ADD_PROGRAM_COUNTER(JumpIfFalse);
Expand Down Expand Up @@ -1771,7 +1771,7 @@ NEVER_INLINE void InterpreterSlowPath::resolveNameAddress(ExecutionState& state,
ObjectPropertyName propertyName(code->m_name);
auto obj = env->record()->asObjectEnvironmentRecord()->bindingObject();
Value unscopables = obj->get(state, ObjectPropertyName(state.context()->vmInstance()->globalSymbols().unscopables)).value(state, obj);
if (UNLIKELY(unscopables.isObject() && unscopables.asObject()->get(state, propertyName).value(state, unscopables).toBoolean(state))) {
if (UNLIKELY(unscopables.isObject() && unscopables.asObject()->get(state, propertyName).value(state, unscopables).toBoolean())) {
foundUnscopables = true;
}
}
Expand Down Expand Up @@ -4516,7 +4516,7 @@ NEVER_INLINE void InterpreterSlowPath::iteratorOperation(ExecutionState& state,
registerFile[code->m_iteratorTestDoneData.m_iteratorRecordOrObjectRegisterIndex].asPointerValue()->asIteratorRecord()->m_done);
} else {
registerFile[code->m_iteratorTestDoneData.m_dstRegisterIndex] = Value(
registerFile[code->m_iteratorTestDoneData.m_iteratorRecordOrObjectRegisterIndex].asObject()->get(state, state.context()->staticStrings().done).value(state, registerFile[code->m_iteratorTestDoneData.m_iteratorRecordOrObjectRegisterIndex]).toBoolean(state));
registerFile[code->m_iteratorTestDoneData.m_iteratorRecordOrObjectRegisterIndex].asObject()->get(state, state.context()->staticStrings().done).value(state, registerFile[code->m_iteratorTestDoneData.m_iteratorRecordOrObjectRegisterIndex]).toBoolean());
}
ADD_PROGRAM_COUNTER(IteratorOperation);
} else if (code->m_operation == IteratorOperation::Operation::IteratorNext) {
Expand Down
2 changes: 1 addition & 1 deletion src/intl/Intl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,7 @@ Value Intl::getOption(ExecutionState& state, Object* options, Value property, In
// Assert: type is "boolean" or "string".
// If type is "boolean", then let value be ToBoolean(value).
if (type == Intl::OptionValueType::BooleanValue) {
value = Value(value.toBoolean(state));
value = Value(value.toBoolean());
}
// If type is "string", then let value be ToString(value).
if (type == Intl::OptionValueType::StringValue) {
Expand Down
4 changes: 2 additions & 2 deletions src/intl/IntlCollator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ IntlCollator::CollatorResolvedOptions IntlCollator::resolvedOptions(ExecutionSta
opt.sensitivity = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().lazySensitivity())).value(state, internalSlot).toString(state);
opt.usage = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().lazyUsage())).value(state, internalSlot).toString(state);
opt.collation = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().collation)).value(state, internalSlot).toString(state);
opt.numeric = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().numeric)).value(state, internalSlot).toBoolean(state);
opt.ignorePunctuation = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().lazyIgnorePunctuation())).value(state, internalSlot).toBoolean(state);
opt.numeric = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().numeric)).value(state, internalSlot).toBoolean();
opt.ignorePunctuation = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().lazyIgnorePunctuation())).value(state, internalSlot).toBoolean();
opt.caseFirst = internalSlot->get(state, ObjectPropertyName(state.context()->staticStrings().caseFirst)).value(state, internalSlot).toString(state);
return opt;
}
Expand Down
2 changes: 1 addition & 1 deletion src/intl/IntlDateTimeFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ String* IntlDateTimeFormatObject::initDateTimeFormatMainHelper(ExecutionState& s
String* hour = ret = opt.at("hour");
Value hr12Value = hour12;
bool isHour12Undefined = hr12Value.isUndefined();
bool hr12 = hr12Value.toBoolean(state);
bool hr12 = hr12Value.toBoolean();

if (isHour12Undefined) {
if (ret->equals("2-digit"))
Expand Down
3 changes: 1 addition & 2 deletions src/parser/ast/WhileStatementNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class WhileStatementNode : public StatementNode {

size_t whileStart = codeBlock->currentCodeSize();
size_t testPos = SIZE_MAX;
ExecutionState stateForTest(codeBlock->m_codeBlock->context());
if (m_test->isLiteral() && m_test->asLiteral()->value().isPrimitive() && m_test->asLiteral()->value().toBoolean(stateForTest)) {
if (m_test->isLiteral() && m_test->asLiteral()->value().isPrimitive() && m_test->asLiteral()->value().toBoolean()) {
// skip generate code
} else {
if (m_test->isRelationOperation()) {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/DataViewObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DataViewObject : public ArrayBufferView {
ErrorObject::throwBuiltinError(state, ErrorCode::RangeError, state.context()->staticStrings().DataView.string(), false, String::emptyString, ErrorObject::Messages::GlobalObject_InvalidArrayBufferOffset);
}

bool isLittleEndian = _isLittleEndian.toBoolean(state);
bool isLittleEndian = _isLittleEndian.toBoolean();
ArrayBuffer* buffer = this->buffer();
buffer->throwTypeErrorIfDetached(state);

Expand All @@ -79,7 +79,7 @@ class DataViewObject : public ArrayBufferView {
auto numericValue = val.toNumeric(state);
UNUSED_VARIABLE(numericValue);

bool isLittleEndian = _isLittleEndian.toBoolean(state);
bool isLittleEndian = _isLittleEndian.toBoolean();
ArrayBuffer* buffer = this->buffer();
buffer->throwTypeErrorIfDetached(state);

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/EnvironmentRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class ObjectEnvironmentRecord : public EnvironmentRecord {
// we check conditions same as hasBinding for performance reason
// directly call getBindingValue instead of checking the result of hasBinding in advance
Value unscopables = m_bindingObject->get(state, ObjectPropertyName(state.context()->vmInstance()->globalSymbols().unscopables)).value(state, m_bindingObject);
if (UNLIKELY(unscopables.isObject() && unscopables.asObject()->get(state, propertyName).value(state, unscopables).toBoolean(state))) {
if (UNLIKELY(unscopables.isObject() && unscopables.asObject()->get(state, propertyName).value(state, unscopables).toBoolean())) {
return GetBindingValueResult();
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/IteratorObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Object* IteratorObject::iteratorNext(ExecutionState& state, IteratorRecord* iter
bool IteratorObject::iteratorComplete(ExecutionState& state, Object* iterResult)
{
Value result = iterResult->get(state, ObjectPropertyName(state.context()->staticStrings().done)).value(state, iterResult);
return result.toBoolean(state);
return result.toBoolean();
}

// https://www.ecma-international.org/ecma-262/10.0/#sec-iteratorvalue
Expand Down
Loading

0 comments on commit f0ddc35

Please sign in to comment.