We can avoid passing the context into many methods now.
Change-Id: I3cfedd679441117c5ea3aa735d5342788d7dfac5
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
uint len;
if (argc == 1 && argv[0].isNumber()) {
bool ok;
- len = argv[0].asArrayLength(ctx, &ok);
+ len = argv[0].asArrayLength(&ok);
if (!ok)
ctx->throwRangeError(argv[0]);
{
if (o->isArrayObject())
return o->arrayLength();
- return o->get(ctx, ctx->engine->id_length).toUInt32(ctx);
+ return o->get(ctx, ctx->engine->id_length).toUInt32();
}
Value ArrayPrototype::method_isArray(SimpleCallContext *ctx)
Value self = ctx->thisObject;
const Value length = self.property(ctx, ctx->engine->id_length);
- const quint32 r2 = Value::toUInt32(length.isUndefined() ? 0 : length.toNumber(ctx));
+ const quint32 r2 = Value::toUInt32(length.isUndefined() ? 0 : length.toNumber());
static QSet<Object *> visitedArrayElements;
Object *o = ctx->thisObject.toObject(ctx);
ArrayObject *result = ctx->engine->newArrayObject(ctx);
- uint len = o->get(ctx, ctx->engine->id_length).toUInt32(ctx);
- double s = ctx->argument(0).toInteger(ctx);
+ uint len = o->get(ctx, ctx->engine->id_length).toUInt32();
+ double s = ctx->argument(0).toInteger();
uint start;
if (s < 0)
start = (uint)qMax(len + s, 0.);
start = (uint) s;
uint end = len;
if (!ctx->argument(1).isUndefined()) {
- double e = ctx->argument(1).toInteger(ctx);
+ double e = ctx->argument(1).toInteger();
if (e < 0)
end = (uint)qMax(len + e, 0.);
else if (e > len)
ArrayObject *newArray = ctx->engine->newArrayObject(ctx);
- double rs = ctx->argument(0).toInteger(ctx);
+ double rs = ctx->argument(0).toInteger();
uint start;
if (rs < 0)
start = (uint) qMax(0., len + rs);
else
start = (uint) qMin(rs, (double)len);
- uint deleteCount = (uint)qMin(qMax(ctx->argument(1).toInteger(ctx), 0.), (double)(len - start));
+ uint deleteCount = (uint)qMin(qMax(ctx->argument(1).toInteger(), 0.), (double)(len - start));
newArray->arrayReserve(deleteCount);
Property *pd = newArray->arrayData;
searchValue = Value::undefinedValue();
if (ctx->argumentCount >= 2) {
- double f = ctx->argument(1).toInteger(ctx);
+ double f = ctx->argument(1).toInteger();
if (f >= len)
return Value::fromInt32(-1);
if (f < 0)
for (uint k = fromIndex; k < len; ++k) {
bool exists;
Value v = instance->getIndexed(ctx, k, &exists);
- if (exists && __qmljs_strict_equal(v, searchValue, ctx))
+ if (exists && __qmljs_strict_equal(v, searchValue))
return Value::fromDouble(k);
}
return Value::fromInt32(-1);
searchValue = Value::undefinedValue();
if (ctx->argumentCount >= 2) {
- double f = ctx->argument(1).toInteger(ctx);
+ double f = ctx->argument(1).toInteger();
if (f > 0)
f = qMin(f, (double)(len - 1));
else if (f < 0) {
--k;
bool exists;
Value v = instance->getIndexed(ctx, k, &exists);
- if (exists && __qmljs_strict_equal(v, searchValue, ctx))
+ if (exists && __qmljs_strict_equal(v, searchValue))
return Value::fromDouble(k);
}
return Value::fromInt32(-1);
if (DateObject *d = arg.asDateObject())
arg = d->value;
else
- arg = __qmljs_to_primitive(arg, ctx, PREFERREDTYPE_HINT);
+ arg = __qmljs_to_primitive(arg, PREFERREDTYPE_HINT);
if (arg.isString())
t = ParseString(arg.stringValue()->toQString());
else
- t = TimeClip(arg.toNumber(ctx));
+ t = TimeClip(arg.toNumber());
}
else { // argc > 1
- double year = args[0].toNumber(ctx);
- double month = args[1].toNumber(ctx);
- double day = argc >= 3 ? args[2].toNumber(ctx) : 1;
- double hours = argc >= 4 ? args[3].toNumber(ctx) : 0;
- double mins = argc >= 5 ? args[4].toNumber(ctx) : 0;
- double secs = argc >= 6 ? args[5].toNumber(ctx) : 0;
- double ms = argc >= 7 ? args[6].toNumber(ctx) : 0;
+ double year = args[0].toNumber();
+ double month = args[1].toNumber();
+ double day = argc >= 3 ? args[2].toNumber() : 1;
+ double hours = argc >= 4 ? args[3].toNumber() : 0;
+ double mins = argc >= 5 ? args[4].toNumber() : 0;
+ double secs = argc >= 6 ? args[5].toNumber() : 0;
+ double ms = argc >= 7 ? args[6].toNumber() : 0;
if (year >= 0 && year <= 99)
year += 1900;
t = MakeDate(MakeDay(year, month, day), MakeTime(hours, mins, secs, ms));
{
const int numArgs = ctx->argumentCount;
if (numArgs >= 2) {
- double year = ctx->argument(0).toNumber(ctx);
- double month = ctx->argument(1).toNumber(ctx);
- double day = numArgs >= 3 ? ctx->argument(2).toNumber(ctx) : 1;
- double hours = numArgs >= 4 ? ctx->argument(3).toNumber(ctx) : 0;
- double mins = numArgs >= 5 ? ctx->argument(4).toNumber(ctx) : 0;
- double secs = numArgs >= 6 ? ctx->argument(5).toNumber(ctx) : 0;
- double ms = numArgs >= 7 ? ctx->argument(6).toNumber(ctx) : 0;
+ double year = ctx->argument(0).toNumber();
+ double month = ctx->argument(1).toNumber();
+ double day = numArgs >= 3 ? ctx->argument(2).toNumber() : 1;
+ double hours = numArgs >= 4 ? ctx->argument(3).toNumber() : 0;
+ double mins = numArgs >= 5 ? ctx->argument(4).toNumber() : 0;
+ double secs = numArgs >= 6 ? ctx->argument(5).toNumber() : 0;
+ double ms = numArgs >= 7 ? ctx->argument(6).toNumber() : 0;
if (year >= 0 && year <= 99)
year += 1900;
double t = MakeDate(MakeDay(year, month, day),
if (!self)
ctx->throwTypeError();
- self->value.setDouble(TimeClip(ctx->argument(0).toNumber(ctx)));
+ self->value.setDouble(TimeClip(ctx->argument(0).toNumber()));
return self->value;
}
ctx->throwTypeError();
double t = LocalTime(self->value.asDouble());
- double ms = ctx->argument(0).toNumber(ctx);
+ double ms = ctx->argument(0).toNumber();
self->value.setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))));
return self->value;
}
ctx->throwTypeError();
double t = self->value.asDouble();
- double ms = ctx->argument(0).toNumber(ctx);
+ double ms = ctx->argument(0).toNumber();
self->value.setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))));
return self->value;
}
ctx->throwTypeError();
double t = LocalTime(self->value.asDouble());
- double sec = ctx->argument(0).toNumber(ctx);
- double ms = (ctx->argumentCount < 2) ? msFromTime(t) : ctx->argument(1).toNumber(ctx);
+ double sec = ctx->argument(0).toNumber();
+ double ms = (ctx->argumentCount < 2) ? msFromTime(t) : ctx->argument(1).toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = self->value.asDouble();
- double sec = ctx->argument(0).toNumber(ctx);
- double ms = (ctx->argumentCount < 2) ? msFromTime(t) : ctx->argument(1).toNumber(ctx);
+ double sec = ctx->argument(0).toNumber();
+ double ms = (ctx->argumentCount < 2) ? msFromTime(t) : ctx->argument(1).toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = LocalTime(self->value.asDouble());
- double min = ctx->argument(0).toNumber(ctx);
- double sec = (ctx->argumentCount < 2) ? SecFromTime(t) : ctx->argument(1).toNumber(ctx);
- double ms = (ctx->argumentCount < 3) ? msFromTime(t) : ctx->argument(2).toNumber(ctx);
+ double min = ctx->argument(0).toNumber();
+ double sec = (ctx->argumentCount < 2) ? SecFromTime(t) : ctx->argument(1).toNumber();
+ double ms = (ctx->argumentCount < 3) ? msFromTime(t) : ctx->argument(2).toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = self->value.asDouble();
- double min = ctx->argument(0).toNumber(ctx);
- double sec = (ctx->argumentCount < 2) ? SecFromTime(t) : ctx->argument(1).toNumber(ctx);
- double ms = (ctx->argumentCount < 3) ? msFromTime(t) : ctx->argument(2).toNumber(ctx);
+ double min = ctx->argument(0).toNumber();
+ double sec = (ctx->argumentCount < 2) ? SecFromTime(t) : ctx->argument(1).toNumber();
+ double ms = (ctx->argumentCount < 3) ? msFromTime(t) : ctx->argument(2).toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = LocalTime(self->value.asDouble());
- double hour = ctx->argument(0).toNumber(ctx);
- double min = (ctx->argumentCount < 2) ? MinFromTime(t) : ctx->argument(1).toNumber(ctx);
- double sec = (ctx->argumentCount < 3) ? SecFromTime(t) : ctx->argument(2).toNumber(ctx);
- double ms = (ctx->argumentCount < 4) ? msFromTime(t) : ctx->argument(3).toNumber(ctx);
+ double hour = ctx->argument(0).toNumber();
+ double min = (ctx->argumentCount < 2) ? MinFromTime(t) : ctx->argument(1).toNumber();
+ double sec = (ctx->argumentCount < 3) ? SecFromTime(t) : ctx->argument(2).toNumber();
+ double ms = (ctx->argumentCount < 4) ? msFromTime(t) : ctx->argument(3).toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = self->value.asDouble();
- double hour = ctx->argument(0).toNumber(ctx);
- double min = (ctx->argumentCount < 2) ? MinFromTime(t) : ctx->argument(1).toNumber(ctx);
- double sec = (ctx->argumentCount < 3) ? SecFromTime(t) : ctx->argument(2).toNumber(ctx);
- double ms = (ctx->argumentCount < 4) ? msFromTime(t) : ctx->argument(3).toNumber(ctx);
+ double hour = ctx->argument(0).toNumber();
+ double min = (ctx->argumentCount < 2) ? MinFromTime(t) : ctx->argument(1).toNumber();
+ double sec = (ctx->argumentCount < 3) ? SecFromTime(t) : ctx->argument(2).toNumber();
+ double ms = (ctx->argumentCount < 4) ? msFromTime(t) : ctx->argument(3).toNumber();
t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = LocalTime(self->value.asDouble());
- double date = ctx->argument(0).toNumber(ctx);
+ double date = ctx->argument(0).toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = self->value.asDouble();
- double date = ctx->argument(0).toNumber(ctx);
+ double date = ctx->argument(0).toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = LocalTime(self->value.asDouble());
- double month = ctx->argument(0).toNumber(ctx);
- double date = (ctx->argumentCount < 2) ? DateFromTime(t) : ctx->argument(1).toNumber(ctx);
+ double month = ctx->argument(0).toNumber();
+ double date = (ctx->argumentCount < 2) ? DateFromTime(t) : ctx->argument(1).toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))));
self->value.setDouble(t);
return self->value;
ctx->throwTypeError();
double t = self->value.asDouble();
- double month = ctx->argument(0).toNumber(ctx);
- double date = (ctx->argumentCount < 2) ? DateFromTime(t) : ctx->argument(1).toNumber(ctx);
+ double month = ctx->argument(0).toNumber();
+ double date = (ctx->argumentCount < 2) ? DateFromTime(t) : ctx->argument(1).toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))));
self->value.setDouble(t);
return self->value;
t = 0;
else
t = LocalTime(t);
- double year = ctx->argument(0).toNumber(ctx);
+ double year = ctx->argument(0).toNumber();
double r;
if (isnan(year)) {
r = qSNaN();
ctx->throwTypeError();
double t = self->value.asDouble();
- double year = ctx->argument(0).toNumber(ctx);
- double month = (ctx->argumentCount < 2) ? MonthFromTime(t) : ctx->argument(1).toNumber(ctx);
- double date = (ctx->argumentCount < 3) ? DateFromTime(t) : ctx->argument(2).toNumber(ctx);
+ double year = ctx->argument(0).toNumber();
+ double month = (ctx->argumentCount < 2) ? MonthFromTime(t) : ctx->argument(1).toNumber();
+ double date = (ctx->argumentCount < 3) ? DateFromTime(t) : ctx->argument(2).toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))));
self->value.setDouble(t);
return self->value;
double t = LocalTime(self->value.asDouble());
if (isnan(t))
t = 0;
- double year = ctx->argument(0).toNumber(ctx);
- double month = (ctx->argumentCount < 2) ? MonthFromTime(t) : ctx->argument(1).toNumber(ctx);
- double date = (ctx->argumentCount < 3) ? DateFromTime(t) : ctx->argument(2).toNumber(ctx);
+ double year = ctx->argument(0).toNumber();
+ double month = (ctx->argumentCount < 2) ? MonthFromTime(t) : ctx->argument(1).toNumber();
+ double date = (ctx->argumentCount < 3) ? DateFromTime(t) : ctx->argument(2).toNumber();
t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))));
self->value.setDouble(t);
return self->value;
Value DatePrototype::method_toJSON(SimpleCallContext *ctx)
{
Value O = __qmljs_to_object(ctx, ctx->thisObject);
- Value tv = __qmljs_to_primitive(O, ctx, NUMBER_HINT);
+ Value tv = __qmljs_to_primitive(O, NUMBER_HINT);
- if (tv.isNumber() && !std::isfinite(tv.toNumber(ctx)))
+ if (tv.isNumber() && !std::isfinite(tv.toNumber()))
return Value::nullValue();
FunctionObject *toIso = O.objectValue()->get(ctx, ctx->engine->newString(QStringLiteral("toISOString"))).asFunctionObject();
QVector<Value> args;
if (Object *arr = arg.asObject()) {
- quint32 len = arr->get(ctx, ctx->engine->id_length).toUInt32(ctx);
+ quint32 len = arr->get(ctx, ctx->engine->id_length).toUInt32();
for (quint32 i = 0; i < len; ++i) {
Value a = arr->getIndexed(ctx, i);
args.append(a);
, boundArgs(boundArgs)
{
vtbl = &static_vtbl;
- int len = target->get(scope, scope->engine->id_length).toUInt32(scope);
+ int len = target->get(scope, scope->engine->id_length).toUInt32();
len -= boundArgs.size();
if (len < 0)
len = 0;
{
Value string = context->argument(0);
Value radix = context->argument(1);
- int R = radix.isUndefined() ? 0 : radix.toInt32(context);
+ int R = radix.isUndefined() ? 0 : radix.toInt32();
// [15.1.2.2] step by step:
String *inputString = string.toString(context); // 1
if (v.integerCompatible())
return Value::fromBoolean(false);
- double d = v.toNumber(context);
+ double d = v.toNumber();
return Value::fromBoolean(isnan(d));
}
if (v.integerCompatible())
return Value::fromBoolean(true);
- double d = v.toNumber(context);
+ double d = v.toNumber();
return Value::fromBoolean(std::isfinite(d));
}
return quote(value.stringValue()->toQString());
if (value.isNumber()) {
- double d = value.toNumber(ctx);
+ double d = value.toNumber();
return std::isfinite(d) ? value.toString(ctx)->toQString() : QStringLiteral("null");
}
s = so->value;
if (s.isNumber()) {
- stringify.gap = QString(qMin(10, (int)s.toInteger(ctx)), ' ');
+ stringify.gap = QString(qMin(10, (int)s.toInteger()), ' ');
} else if (s.isString()) {
stringify.gap = s.stringValue()->toQString().left(10);
}
return Value::fromInt32(i < 0 ? - i : i);
}
- double v = context->arguments[0].toNumber(context);
+ double v = context->arguments[0].toNumber();
if (v == 0) // 0 | -0
return Value::fromDouble(0);
Value MathObject::method_acos(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : 2;
+ double v = context->argumentCount ? context->arguments[0].toNumber() : 2;
if (v > 1)
return Value::fromDouble(qSNaN());
Value MathObject::method_asin(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : 2;
+ double v = context->argumentCount ? context->arguments[0].toNumber() : 2;
if (v > 1)
return Value::fromDouble(qSNaN());
else
Value MathObject::method_atan(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
if (v == 0.0)
return Value::fromDouble(v);
else
Value MathObject::method_atan2(SimpleCallContext *context)
{
- double v1 = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
- double v2 = context->argumentCount > 1 ? context->arguments[1].toNumber(context) : qSNaN();
+ double v1 = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
+ double v2 = context->argumentCount > 1 ? context->arguments[1].toNumber() : qSNaN();
if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0))
return Value::fromDouble(copySign(0, -1.0));
Value MathObject::method_ceil(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
if (v < 0.0 && v > -1.0)
return Value::fromDouble(copySign(0, -1.0));
else
Value MathObject::method_cos(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
return Value::fromDouble(::cos(v));
}
Value MathObject::method_exp(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
if (qIsInf(v)) {
if (copySign(1.0, v) == -1.0)
return Value::fromDouble(0);
Value MathObject::method_floor(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
return Value::fromDouble(::floor(v));
}
Value MathObject::method_log(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
if (v < 0)
return Value::fromDouble(qSNaN());
else
{
double mx = -qInf();
for (unsigned i = 0; i < context->argumentCount; ++i) {
- double x = context->arguments[i].toNumber(context);
+ double x = context->arguments[i].toNumber();
if (x > mx || isnan(x))
mx = x;
}
{
double mx = qInf();
for (unsigned i = 0; i < context->argumentCount; ++i) {
- double x = context->arguments[i].toNumber(context);
+ double x = context->arguments[i].toNumber();
if ((x == 0 && mx == x && copySign(1.0, x) == -1.0)
|| (x < mx) || isnan(x)) {
mx = x;
Value MathObject::method_pow(SimpleCallContext *context)
{
- double x = context->argumentCount > 0 ? context->arguments[0].toNumber(context) : qSNaN();
- double y = context->argumentCount > 1 ? context->arguments[1].toNumber(context) : qSNaN();
+ double x = context->argumentCount > 0 ? context->arguments[0].toNumber() : qSNaN();
+ double y = context->argumentCount > 1 ? context->arguments[1].toNumber() : qSNaN();
if (isnan(y))
return Value::fromDouble(qSNaN());
Value MathObject::method_round(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
v = copySign(::floor(v + 0.5), v);
return Value::fromDouble(v);
}
Value MathObject::method_sin(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
return Value::fromDouble(::sin(v));
}
Value MathObject::method_sqrt(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
return Value::fromDouble(::sqrt(v));
}
Value MathObject::method_tan(SimpleCallContext *context)
{
- double v = context->argumentCount ? context->arguments[0].toNumber(context) : qSNaN();
+ double v = context->argumentCount ? context->arguments[0].toNumber() : qSNaN();
if (v == 0.0)
return Value::fromDouble(v);
else
Value NumberCtor::construct(Managed *, ExecutionContext *ctx, Value *args, int argc)
{
- double d = argc ? args[0].toNumber(ctx) : 0.;
+ double d = argc ? args[0].toNumber() : 0.;
return Value::fromObject(ctx->engine->newNumberObject(Value::fromDouble(d)));
}
Value NumberCtor::call(Managed *m, ExecutionContext *parentCtx, const Value &thisObject, Value *argv, int argc)
{
- double d = argc ? argv[0].toNumber(parentCtx) : 0.;
+ double d = argc ? argv[0].toNumber() : 0.;
return Value::fromDouble(d);
}
Value arg = ctx->argument(0);
if (!arg.isUndefined()) {
- int radix = arg.toInt32(ctx);
+ int radix = arg.toInt32();
if (radix < 2 || radix > 36) {
ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix")
.arg(radix));
double fdigits = 0;
if (ctx->argumentCount > 0)
- fdigits = ctx->argument(0).toInteger(ctx);
+ fdigits = ctx->argument(0).toInteger();
if (isnan(fdigits))
fdigits = 0;
double fdigits = 0;
if (ctx->argumentCount > 0)
- fdigits = ctx->argument(0).toInteger(ctx);
+ fdigits = ctx->argument(0).toInteger();
QString z = QString::number(thisObject->value.asDouble(), 'e', int (fdigits));
return Value::fromString(ctx, z);
double fdigits = 0;
if (ctx->argumentCount > 0)
- fdigits = ctx->argument(0).toInteger(ctx);
+ fdigits = ctx->argument(0).toInteger();
return Value::fromString(ctx, QString::number(thisObject->value.asDouble(), 'g', int (fdigits)));
}
goto reject;
else if (isArrayObject() && name->isEqualTo(ctx->engine->id_length)) {
bool ok;
- uint l = value.asArrayLength(ctx, &ok);
+ uint l = value.asArrayLength(&ok);
if (!ok)
ctx->throwRangeError(value);
ok = setArrayLength(l);
bool succeeded = true;
if (attrs.type() == PropertyAttributes::Data) {
bool ok;
- uint l = p.value.asArrayLength(ctx, &ok);
+ uint l = p.value.asArrayLength(&ok);
if (!ok)
ctx->throwRangeError(p.value);
succeeded = setArrayLength(l);
for (uint i = fromIndex; i < endIndex; ++i) {
bool exists;
Value value = o->getIndexed(ctx, i, &exists);
- if (exists && __qmljs_strict_equal(value, v, ctx))
+ if (exists && __qmljs_strict_equal(value, v))
return Value::fromDouble(i);
}
} else if (sparseArray) {
for (SparseArrayNode *n = sparseArray->lowerBound(fromIndex); n != sparseArray->end() && n->key() < endIndex; n = n->nextNode()) {
Value value = o->getValue(ctx, arrayData + n->value, arrayAttributes ? arrayAttributes[n->value] : Attr_Data);
- if (__qmljs_strict_equal(value, v, ctx))
+ if (__qmljs_strict_equal(value, v))
return Value::fromDouble(n->key());
}
} else {
while (pd < end) {
if (!arrayAttributes || !arrayAttributes[pd - arrayData].isGeneric()) {
Value value = o->getValue(ctx, pd, arrayAttributes ? arrayAttributes[pd - arrayData] : Attr_Data);
- if (__qmljs_strict_equal(value, v, ctx))
+ if (__qmljs_strict_equal(value, v))
return Value::fromDouble(pd - arrayData);
}
++pd;
arg = __qmljs_to_string(arg, ctx);
QString s = arg.stringValue()->toQString();
- int offset = r->global ? r->lastIndexProperty(ctx)->value.toInt32(ctx) : 0;
+ int offset = r->global ? r->lastIndexProperty(ctx)->value.toInt32() : 0;
if (offset < 0 || offset > s.length()) {
r->lastIndexProperty(ctx)->value = Value::fromInt32(0);
return Value::nullValue();
void __qmljs_add_helper(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
{
- Value pleft = __qmljs_to_primitive(left, ctx, PREFERREDTYPE_HINT);
- Value pright = __qmljs_to_primitive(right, ctx, PREFERREDTYPE_HINT);
+ Value pleft = __qmljs_to_primitive(left, PREFERREDTYPE_HINT);
+ Value pright = __qmljs_to_primitive(right, PREFERREDTYPE_HINT);
if (pleft.isString() || pright.isString()) {
if (!pleft.isString())
pleft = __qmljs_to_string(pleft, ctx);
*result = Value::fromString(string);
return;
}
- double x = __qmljs_to_number(pleft, ctx);
- double y = __qmljs_to_number(pright, ctx);
+ double x = __qmljs_to_number(pleft);
+ double y = __qmljs_to_number(pright);
*result = Value::fromDouble(x + y);
}
return Value::fromString(string);
}
-Bool __qmljs_string_compare(ExecutionContext *, String *left, String *right)
+Bool __qmljs_string_compare(String *left, String *right)
{
return left->toQString() < right->toQString();
}
return ctx->engine->newString(newStr);
}
-Value __qmljs_object_default_value(ExecutionContext *ctx, Value object, int typeHint)
+Value __qmljs_object_default_value(Object *object, int typeHint)
{
if (typeHint == PREFERREDTYPE_HINT) {
- if (object.asDateObject())
+ if (object->asDateObject())
typeHint = STRING_HINT;
else
typeHint = NUMBER_HINT;
}
- String *meth1 = ctx->engine->newString("toString");
- String *meth2 = ctx->engine->newString("valueOf");
+ ExecutionEngine *engine = object->internalClass->engine;
+ String *meth1 = engine->newString("toString");
+ String *meth2 = engine->newString("valueOf");
if (typeHint == NUMBER_HINT)
qSwap(meth1, meth2);
- assert(object.isObject());
- Object *oo = object.objectValue();
+ ExecutionContext *ctx = engine->current;
- Value conv = oo->get(ctx, meth1);
+ Value conv = object->get(ctx, meth1);
if (FunctionObject *o = conv.asFunctionObject()) {
- Value r = o->call(ctx, object, 0, 0);
+ Value r = o->call(ctx, Value::fromObject(object), 0, 0);
if (r.isPrimitive())
return r;
}
- conv = oo->get(ctx, meth2);
+ conv = object->get(ctx, meth2);
if (FunctionObject *o = conv.asFunctionObject()) {
- Value r = o->call(ctx, object, 0, 0);
+ Value r = o->call(ctx, Value::fromObject(object), 0, 0);
if (r.isPrimitive())
return r;
}
case Value::String_Type:
return value.stringValue();
case Value::Object_Type: {
- Value prim = __qmljs_to_primitive(value, ctx, STRING_HINT);
+ Value prim = __qmljs_to_primitive(value, STRING_HINT);
if (prim.isPrimitive())
return __qmljs_convert_to_string(ctx, prim);
else
*result = ctx->thisObject;
}
-uint __qmljs_equal(const Value &x, const Value &y, ExecutionContext *ctx)
+uint __qmljs_equal(const Value &x, const Value &y)
{
if (x.type() == y.type()) {
switch (x.type()) {
return x.stringValue()->isEqualTo(y.stringValue());
case Value::Object_Type:
if (x.objectValue()->externalComparison || y.objectValue()->externalComparison)
- return x.objectValue()->externalComparison && y.objectValue()->externalComparison && ctx->engine->externalResourceComparison(x, y);
+ return x.objectValue()->externalComparison && y.objectValue()->externalComparison
+ && x.objectValue()->internalClass->engine->externalResourceComparison(x, y);
return x.objectValue() == y.objectValue();
default: // double
return x.doubleValue() == y.doubleValue();
} else if (x.isUndefined() && y.isNull()) {
return true;
} else if (x.isNumber() && y.isString()) {
- Value ny = Value::fromDouble(__qmljs_to_number(y, ctx));
- return __qmljs_equal(x, ny, ctx);
+ Value ny = Value::fromDouble(__qmljs_to_number(y));
+ return __qmljs_equal(x, ny);
} else if (x.isString() && y.isNumber()) {
- Value nx = Value::fromDouble(__qmljs_to_number(x, ctx));
- return __qmljs_equal(nx, y, ctx);
+ Value nx = Value::fromDouble(__qmljs_to_number(x));
+ return __qmljs_equal(nx, y);
} else if (x.isBoolean()) {
Value nx = Value::fromDouble((double) x.booleanValue());
- return __qmljs_equal(nx, y, ctx);
+ return __qmljs_equal(nx, y);
} else if (y.isBoolean()) {
Value ny = Value::fromDouble((double) y.booleanValue());
- return __qmljs_equal(x, ny, ctx);
+ return __qmljs_equal(x, ny);
} else if ((x.isNumber() || x.isString()) && y.isObject()) {
- Value py = __qmljs_to_primitive(y, ctx, PREFERREDTYPE_HINT);
- return __qmljs_equal(x, py, ctx);
+ Value py = __qmljs_to_primitive(y, PREFERREDTYPE_HINT);
+ return __qmljs_equal(x, py);
} else if (x.isObject() && (y.isNumber() || y.isString())) {
- Value px = __qmljs_to_primitive(x, ctx, PREFERREDTYPE_HINT);
- return __qmljs_equal(px, y, ctx);
+ Value px = __qmljs_to_primitive(x, PREFERREDTYPE_HINT);
+ return __qmljs_equal(px, y);
}
}
return false;
}
-Bool __qmljs_strict_equal(const Value &x, const Value &y, ExecutionContext *ctx)
+Bool __qmljs_strict_equal(const Value &x, const Value &y)
{
TRACE2(x, y);
if (x.isString())
return __qmljs_string_equal(x.stringValue(), y.stringValue());
if (x.isObject() && x.objectValue()->externalComparison && y.objectValue()->externalComparison)
- return ctx->engine->externalResourceComparison(x, y);
+ return x.objectValue()->internalClass->engine->externalResourceComparison(x, y);
return false;
}
return;
}
- double d = __qmljs_to_number(*val, ctx);
+ double d = __qmljs_to_number(*val);
*val = Value::fromDouble(d + 1);
if (result)
*result = Value::fromDouble(d);
*result = v;
v.int_32 += 1;
} else {
- double d = __qmljs_to_number(v, context);
+ double d = __qmljs_to_number(v);
if (result)
*result = Value::fromDouble(d);
v = Value::fromDouble(d + 1);
*result = v;
v.int_32 += 1;
} else {
- double d = __qmljs_to_number(v, context);
+ double d = __qmljs_to_number(v);
if (result)
*result = Value::fromDouble(d);
v = Value::fromDouble(d + 1);
*result = v;
v.int_32 += 1;
} else {
- double d = __qmljs_to_number(v, context);
+ double d = __qmljs_to_number(v);
if (result)
*result = Value::fromDouble(d);
v = Value::fromDouble(d + 1);
return;
}
- double d = __qmljs_to_number(*val, ctx);
+ double d = __qmljs_to_number(*val);
*val = Value::fromDouble(d - 1);
if (result)
*result = Value::fromDouble(d);
*result = v;
v.int_32 -= 1;
} else {
- double d = __qmljs_to_number(v, context);
+ double d = __qmljs_to_number(v);
if (result)
*result = Value::fromDouble(d);
v = Value::fromDouble(d - 1);
*result = v;
v.int_32 -= 1;
} else {
- double d = __qmljs_to_number(v, context);
+ double d = __qmljs_to_number(v);
if (result)
*result = Value::fromDouble(d);
v = Value::fromDouble(d - 1);
*result = v;
v.int_32 -= 1;
} else {
- double d = __qmljs_to_number(v, context);
+ double d = __qmljs_to_number(v);
if (result)
*result = Value::fromDouble(d);
v = Value::fromDouble(d - 1);
pd->setSetter(setter ? setter->asFunctionObject() : 0);
}
-void __qmljs_increment(ExecutionContext *ctx, Value *result, const Value &value)
+void __qmljs_increment(ExecutionContext *, Value *result, const Value &value)
{
TRACE1(value);
if (value.isInteger())
*result = Value::fromInt32(value.integerValue() + 1);
else {
- double d = __qmljs_to_number(value, ctx);
+ double d = __qmljs_to_number(value);
*result = Value::fromDouble(d + 1);
}
}
-void __qmljs_decrement(ExecutionContext *ctx, Value *result, const Value &value)
+void __qmljs_decrement(ExecutionContext *, Value *result, const Value &value)
{
TRACE1(value);
if (value.isInteger())
*result = Value::fromInt32(value.integerValue() - 1);
else {
- double d = __qmljs_to_number(value, ctx);
+ double d = __qmljs_to_number(value);
*result = Value::fromDouble(d - 1);
}
}
// strings
double __qmljs_string_to_number(const String *string);
Value __qmljs_string_from_number(ExecutionContext *ctx, double number);
-Bool __qmljs_string_compare(ExecutionContext *ctx, String *left, String *right);
+Bool __qmljs_string_compare(String *left, String *right);
Bool __qmljs_string_equal(String *left, String *right);
String *__qmljs_string_concat(ExecutionContext *ctx, String *first, String *second);
// objects
-Value __qmljs_object_default_value(ExecutionContext *ctx, Value object, int typeHint);
+Value __qmljs_object_default_value(Object *object, int typeHint);
void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const Value& value);
void __qmljs_set_property(ExecutionContext *ctx, const Value &object, String *name, const Value &value);
void __qmljs_get_property(ExecutionContext *ctx, Value *result, const Value &object, String *name);
void __qmljs_get_thisObject(ExecutionContext *ctx, Value *result);
// type conversion and testing
-Value __qmljs_to_primitive(const Value &value, ExecutionContext *ctx, int typeHint);
+Value __qmljs_to_primitive(const Value &value, int typeHint);
Bool __qmljs_to_boolean(const Value &value);
-double __qmljs_to_number(const Value &value, ExecutionContext *ctx);
+double __qmljs_to_number(const Value &value);
Value __qmljs_to_string(const Value &value, ExecutionContext *ctx);
Q_V4_EXPORT String *__qmljs_convert_to_string(ExecutionContext *ctx, const Value &value);
Value __qmljs_to_object(ExecutionContext *ctx, const Value &value);
Object *__qmljs_convert_to_object(ExecutionContext *ctx, const Value &value);
-Value __qmljs_default_value(const Value &value, ExecutionContext *ctx, int typeHint);
-Bool __qmljs_equal(const Value &x, const Value &y, ExecutionContext *ctx);
-Bool __qmljs_strict_equal(const Value &x, const Value &y, QQmlJS::VM::ExecutionContext *ctx);
+Bool __qmljs_equal(const Value &x, const Value &y);
+Bool __qmljs_strict_equal(const Value &x, const Value &y);
// unary operators
typedef void (*UnaryOpName)(ExecutionContext *, Value *, const Value &);
-void __qmljs_uplus(ExecutionContext *ctx, Value *result, const Value &value);
-void __qmljs_uminus(ExecutionContext *ctx, Value *result, const Value &value);
-void __qmljs_compl(ExecutionContext *ctx, Value *result, const Value &value);
-void __qmljs_not(ExecutionContext *ctx, Value *result, const Value &value);
-void __qmljs_increment(ExecutionContext *ctx, Value *result, const Value &value);
-void __qmljs_decrement(ExecutionContext *ctx, Value *result, const Value &value);
+void __qmljs_uplus(ExecutionContext *, Value *result, const Value &value);
+void __qmljs_uminus(ExecutionContext *, Value *result, const Value &value);
+void __qmljs_compl(ExecutionContext *, Value *result, const Value &value);
+void __qmljs_not(ExecutionContext *, Value *result, const Value &value);
+void __qmljs_increment(ExecutionContext *, Value *result, const Value &value);
+void __qmljs_decrement(ExecutionContext *, Value *result, const Value &value);
void __qmljs_delete_subscript(ExecutionContext *ctx, Value *result, const Value &base, const Value &index);
void __qmljs_delete_member(ExecutionContext *ctx, Value *result, const Value &base, String *name);
void __qmljs_instanceof(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_in(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_bit_or(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_bit_xor(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_bit_and(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_bit_or(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_bit_xor(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_bit_and(ExecutionContext *, Value *result, const Value &left, const Value &right);
void __qmljs_add(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_sub(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_mul(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_div(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_mod(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_shl(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_shr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_ushr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_sub(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_mul(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_div(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_mod(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_shl(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_shr(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_ushr(ExecutionContext *, Value *result, const Value &left, const Value &right);
void __qmljs_gt(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_lt(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_ge(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_le(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_eq(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_ne(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_se(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
-void __qmljs_sne(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
+void __qmljs_se(ExecutionContext *, Value *result, const Value &left, const Value &right);
+void __qmljs_sne(ExecutionContext *, Value *result, const Value &left, const Value &right);
void __qmljs_add_helper(ExecutionContext *ctx, Value *result, const Value &left, const Value &right);
void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const Value &base, String *name, const Value &rhs);
typedef Bool (*CmpOp)(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_gt(ExecutionContext *, const Value &left, const Value &right);
+Bool __qmljs_cmp_lt(ExecutionContext *, const Value &left, const Value &right);
+Bool __qmljs_cmp_ge(ExecutionContext *, const Value &left, const Value &right);
+Bool __qmljs_cmp_le(ExecutionContext *, const Value &left, const Value &right);
+Bool __qmljs_cmp_eq(ExecutionContext *, const Value &left, const Value &right);
Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_se(ExecutionContext *ctx, const Value &left, const Value &right);
-Bool __qmljs_cmp_sne(ExecutionContext *ctx, const Value &left, const Value &right);
+Bool __qmljs_cmp_se(ExecutionContext *, const Value &left, const Value &right);
+Bool __qmljs_cmp_sne(ExecutionContext *, const Value &left, const Value &right);
Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value &left, const Value &right);
Bool __qmljs_cmp_in(ExecutionContext *ctx, const Value &left, const Value &right);
// type conversion and testing
-inline Value __qmljs_to_primitive(const Value &value, ExecutionContext *ctx, int typeHint)
+inline Value __qmljs_to_primitive(const Value &value, int typeHint)
{
- if (!value.isObject())
+ Object *o = value.asObject();
+ if (!o)
return value;
- return __qmljs_default_value(value, ctx, typeHint);
+ return __qmljs_object_default_value(o, typeHint);
}
-inline double __qmljs_to_number(const Value &value, ExecutionContext *ctx)
+inline double __qmljs_to_number(const Value &value)
{
switch (value.type()) {
case Value::Undefined_Type:
case Value::String_Type:
return __qmljs_string_to_number(value.stringValue());
case Value::Object_Type: {
- Value prim = __qmljs_to_primitive(value, ctx, NUMBER_HINT);
- return __qmljs_to_number(prim, ctx);
+ Value prim = __qmljs_to_primitive(value, NUMBER_HINT);
+ return __qmljs_to_number(prim);
}
default: // double
return value.doubleValue();
}
-inline Value __qmljs_default_value(const Value &value, ExecutionContext *ctx, int typeHint)
-{
- if (value.isObject())
- return __qmljs_object_default_value(ctx, value, typeHint);
- return Value::undefinedValue();
-}
-
-
-inline void __qmljs_uplus(ExecutionContext *ctx, Value *result, const Value &value)
+inline void __qmljs_uplus(ExecutionContext *, Value *result, const Value &value)
{
TRACE1(value);
if (result->tryIntegerConversion())
return;
- double n = __qmljs_to_number(value, ctx);
+ double n = __qmljs_to_number(value);
*result = Value::fromDouble(n);
}
-inline void __qmljs_uminus(ExecutionContext *ctx, Value *result, const Value &value)
+inline void __qmljs_uminus(ExecutionContext *, Value *result, const Value &value)
{
TRACE1(value);
if (value.isInteger() && value.integerValue())
*result = Value::fromInt32(-value.integerValue());
else {
- double n = __qmljs_to_number(value, ctx);
+ double n = __qmljs_to_number(value);
*result = Value::fromDouble(-n);
}
}
-inline void __qmljs_compl(ExecutionContext *ctx, Value *result, const Value &value)
+inline void __qmljs_compl(ExecutionContext *, Value *result, const Value &value)
{
TRACE1(value);
if (value.isConvertibleToInt())
n = value.int_32;
else
- n = Value::toInt32(__qmljs_to_number(value, ctx));
+ n = Value::toInt32(__qmljs_to_number(value));
*result = Value::fromInt32(~n);
}
}
// binary operators
-inline void __qmljs_bit_or(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_bit_or(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
return;
}
- int lval = Value::toInt32(__qmljs_to_number(left, ctx));
- int rval = Value::toInt32(__qmljs_to_number(right, ctx));
+ int lval = Value::toInt32(__qmljs_to_number(left));
+ int rval = Value::toInt32(__qmljs_to_number(right));
*result = Value::fromInt32(lval | rval);
}
-inline void __qmljs_bit_xor(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_bit_xor(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
return;
}
- int lval = Value::toInt32(__qmljs_to_number(left, ctx));
- int rval = Value::toInt32(__qmljs_to_number(right, ctx));
+ int lval = Value::toInt32(__qmljs_to_number(left));
+ int rval = Value::toInt32(__qmljs_to_number(right));
*result = Value::fromInt32(lval ^ rval);
}
-inline void __qmljs_bit_and(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_bit_and(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
return;
}
- int lval = Value::toInt32(__qmljs_to_number(left, ctx));
- int rval = Value::toInt32(__qmljs_to_number(right, ctx));
+ int lval = Value::toInt32(__qmljs_to_number(left));
+ int rval = Value::toInt32(__qmljs_to_number(right));
*result = Value::fromInt32(lval & rval);
}
__qmljs_add_helper(ctx, result, left, right);
}
-inline void __qmljs_sub(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_sub(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
}
#endif
- double lval = __qmljs_to_number(left, ctx);
- double rval = __qmljs_to_number(right, ctx);
+ double lval = __qmljs_to_number(left);
+ double rval = __qmljs_to_number(right);
*result = Value::fromDouble(lval - rval);
}
-inline void __qmljs_mul(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_mul(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
}
#endif
- double lval = __qmljs_to_number(left, ctx);
- double rval = __qmljs_to_number(right, ctx);
+ double lval = __qmljs_to_number(left);
+ double rval = __qmljs_to_number(right);
*result = Value::fromDouble(lval * rval);
}
-inline void __qmljs_div(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_div(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- double lval = __qmljs_to_number(left, ctx);
- double rval = __qmljs_to_number(right, ctx);
+ double lval = __qmljs_to_number(left);
+ double rval = __qmljs_to_number(right);
*result = Value::fromDouble(lval / rval);
}
-inline void __qmljs_mod(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_mod(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
}
}
- double lval = __qmljs_to_number(left, ctx);
- double rval = __qmljs_to_number(right, ctx);
+ double lval = __qmljs_to_number(left);
+ double rval = __qmljs_to_number(right);
*result = Value::fromDouble(fmod(lval, rval));
}
-inline void __qmljs_shl(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_shl(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
return;
}
- int lval = Value::toInt32(__qmljs_to_number(left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
+ int lval = Value::toInt32(__qmljs_to_number(left));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right)) & 0x1f;
*result = Value::fromInt32(lval << rval);
}
-inline void __qmljs_shr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_shr(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
return;
}
- int lval = Value::toInt32(__qmljs_to_number(left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
+ int lval = Value::toInt32(__qmljs_to_number(left));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right)) & 0x1f;
*result = Value::fromInt32(lval >> rval);
}
-inline void __qmljs_ushr(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_ushr(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
if (Value::integerCompatible(left, right)) {
res = uint(left.integerValue()) >> (uint(right.integerValue()) & 0x1f);
} else {
- unsigned lval = Value::toUInt32(__qmljs_to_number(left, ctx));
- unsigned rval = Value::toUInt32(__qmljs_to_number(right, ctx)) & 0x1f;
+ unsigned lval = Value::toUInt32(__qmljs_to_number(left));
+ unsigned rval = Value::toUInt32(__qmljs_to_number(right)) & 0x1f;
res = lval >> rval;
}
*result = Value::fromBoolean(!__qmljs_cmp_eq(ctx, left, right));
}
-inline void __qmljs_se(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_se(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- bool r = __qmljs_strict_equal(left, right, ctx);
+ bool r = __qmljs_strict_equal(left, right);
*result = Value::fromBoolean(r);
}
-inline void __qmljs_sne(ExecutionContext *ctx, Value *result, const Value &left, const Value &right)
+inline void __qmljs_sne(ExecutionContext *, Value *result, const Value &left, const Value &right)
{
TRACE2(left, right);
- bool r = ! __qmljs_strict_equal(left, right, ctx);
+ bool r = ! __qmljs_strict_equal(left, right);
*result = Value::fromBoolean(r);
}
-inline Bool __qmljs_cmp_gt(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_gt(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
if (Value::integerCompatible(left, right))
return left.integerValue() > right.integerValue();
- Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, NUMBER_HINT);
if (Value::bothDouble(l, r)) {
return l.doubleValue() > r.doubleValue();
} else if (l.isString() && r.isString()) {
- return __qmljs_string_compare(ctx, r.stringValue(), l.stringValue());
+ return __qmljs_string_compare(r.stringValue(), l.stringValue());
} else {
- double dl = __qmljs_to_number(l, ctx);
- double dr = __qmljs_to_number(r, ctx);
+ double dl = __qmljs_to_number(l);
+ double dr = __qmljs_to_number(r);
return dl > dr;
}
}
-inline Bool __qmljs_cmp_lt(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_lt(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
if (Value::integerCompatible(left, right))
return left.integerValue() < right.integerValue();
- Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, NUMBER_HINT);
if (Value::bothDouble(l, r)) {
return l.doubleValue() < r.doubleValue();
} else if (l.isString() && r.isString()) {
- return __qmljs_string_compare(ctx, l.stringValue(), r.stringValue());
+ return __qmljs_string_compare(l.stringValue(), r.stringValue());
} else {
- double dl = __qmljs_to_number(l, ctx);
- double dr = __qmljs_to_number(r, ctx);
+ double dl = __qmljs_to_number(l);
+ double dr = __qmljs_to_number(r);
return dl < dr;
}
}
-inline Bool __qmljs_cmp_ge(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_ge(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
if (Value::integerCompatible(left, right))
return left.integerValue() >= right.integerValue();
- Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, NUMBER_HINT);
if (Value::bothDouble(l, r)) {
return l.doubleValue() >= r.doubleValue();
} else if (l.isString() && r.isString()) {
- return !__qmljs_string_compare(ctx, l.stringValue(), r.stringValue());
+ return !__qmljs_string_compare(l.stringValue(), r.stringValue());
} else {
- double dl = __qmljs_to_number(l, ctx);
- double dr = __qmljs_to_number(r, ctx);
+ double dl = __qmljs_to_number(l);
+ double dr = __qmljs_to_number(r);
return dl >= dr;
}
}
-inline Bool __qmljs_cmp_le(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_le(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
if (Value::integerCompatible(left, right))
return left.integerValue() <= right.integerValue();
- Value l = __qmljs_to_primitive(left, ctx, NUMBER_HINT);
- Value r = __qmljs_to_primitive(right, ctx, NUMBER_HINT);
+ Value l = __qmljs_to_primitive(left, NUMBER_HINT);
+ Value r = __qmljs_to_primitive(right, NUMBER_HINT);
if (Value::bothDouble(l, r)) {
return l.doubleValue() <= r.doubleValue();
} else if (l.isString() && r.isString()) {
- return !__qmljs_string_compare(ctx, r.stringValue(), l.stringValue());
+ return !__qmljs_string_compare(r.stringValue(), l.stringValue());
} else {
- double dl = __qmljs_to_number(l, ctx);
- double dr = __qmljs_to_number(r, ctx);
+ double dl = __qmljs_to_number(l);
+ double dr = __qmljs_to_number(r);
return dl <= dr;
}
}
-inline Bool __qmljs_cmp_eq(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_eq(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
if (left.isString() && right.isString())
return __qmljs_string_equal(left.stringValue(), right.stringValue());
- return __qmljs_equal(left, right, ctx);
+ return __qmljs_equal(left, right);
}
inline Bool __qmljs_cmp_ne(ExecutionContext *ctx, const Value &left, const Value &right)
return !__qmljs_cmp_eq(ctx, left, right);
}
-inline Bool __qmljs_cmp_se(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_se(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
- return __qmljs_strict_equal(left, right, ctx);
+ return __qmljs_strict_equal(left, right);
}
-inline Bool __qmljs_cmp_sne(ExecutionContext *ctx, const Value &left, const Value &right)
+inline Bool __qmljs_cmp_sne(ExecutionContext *, const Value &left, const Value &right)
{
TRACE2(left, right);
- return ! __qmljs_strict_equal(left, right, ctx);
+ return ! __qmljs_strict_equal(left, right);
}
inline Bool __qmljs_cmp_instanceof(ExecutionContext *ctx, const Value &left, const Value &right)
Value args[] = { v1, v2 };
Value result = Value::undefinedValue();
__qmljs_call_value(m_context, &result, /*thisObject*/0, m_comparefn, args, 2);
- return result.toNumber(m_context) <= 0;
+ return result.toNumber() <= 0;
}
return v1.toString(m_context)->toQString() < v2.toString(m_context)->toQString();
}
int pos = 0;
if (context->argumentCount > 0)
- pos = (int) context->arguments[0].toInteger(context);
+ pos = (int) context->arguments[0].toInteger();
QString result;
if (pos >= 0 && pos < str.length())
int pos = 0;
if (context->argumentCount > 0)
- pos = (int) context->arguments[0].toInteger(context);
+ pos = (int) context->arguments[0].toInteger();
if (pos >= 0 && pos < str.length())
int pos = 0;
if (context->argumentCount > 1)
- pos = (int) context->arguments[1].toInteger(context);
+ pos = (int) context->arguments[1].toInteger();
int index = -1;
if (! value.isEmpty())
}
Value posArg = context->argumentCount > 1 ? context->arguments[1] : Value::undefinedValue();
- double position = __qmljs_to_number(posArg, context);
+ double position = __qmljs_to_number(posArg);
if (isnan(position))
position = +qInf();
else
if (result.isNull())
break;
assert(result.isObject());
- double thisIndex = rx->get(context, lastIndex, 0).toInteger(context);
+ double thisIndex = rx->get(context, lastIndex, 0).toInteger();
if (previousLastIndex == thisIndex) {
previousLastIndex = thisIndex + 1;
rx->put(context, lastIndex, Value::fromDouble(previousLastIndex));
const QString text = getThisString(ctx);
const double length = text.length();
- double start = ctx->argument(0).toInteger(ctx);
+ double start = ctx->argument(0).toInteger();
double end = ctx->argument(1).isUndefined()
- ? length : ctx->argument(1).toInteger(ctx);
+ ? length : ctx->argument(1).toInteger();
if (start < 0)
start = qMax(length + start, 0.);
array->push_back(Value::fromString(ctx, text));
return result;
}
- return Value::fromString(ctx, text.left(limitValue.toInteger(ctx)));
+ return Value::fromString(ctx, text.left(limitValue.toInteger()));
}
- uint limit = limitValue.isUndefined() ? UINT_MAX : limitValue.toUInt32(ctx);
+ uint limit = limitValue.isUndefined() ? UINT_MAX : limitValue.toUInt32();
if (limit == 0)
return result;
double start = 0;
if (context->argumentCount > 0)
- start = context->arguments[0].toInteger(context);
+ start = context->arguments[0].toInteger();
double length = +qInf();
if (context->argumentCount > 1)
- length = context->arguments[1].toInteger(context);
+ length = context->arguments[1].toInteger();
double count = value.length();
if (start < 0)
double end = length;
if (context->argumentCount > 0)
- start = context->arguments[0].toInteger(context);
+ start = context->arguments[0].toInteger();
Value endValue = context->argumentCount > 1 ? context->arguments[1] : Value::undefinedValue();
if (!endValue.isUndefined())
- end = endValue.toInteger(context);
+ end = endValue.toInteger();
if (isnan(start) || start < 0)
start = 0;
QString str(context->argumentCount, Qt::Uninitialized);
QChar *ch = str.data();
for (int i = 0; i < context->argumentCount; ++i) {
- *ch = QChar(context->arguments[i].toUInt16(context));
+ *ch = QChar(context->arguments[i].toUInt16());
++ch;
}
return Value::fromString(context, str);
Local<Number> Value::ToNumber() const
{
- return Local<Number>::New(Value::fromVmValue(VM::Value::fromDouble(ConstValuePtr(this)->toNumber(currentEngine()->current))));
+ return Local<Number>::New(Value::fromVmValue(VM::Value::fromDouble(ConstValuePtr(this)->toNumber())));
}
Local<String> Value::ToString() const
Local<Integer> Value::ToInteger() const
{
- return Local<Integer>::New(Value::fromVmValue(QQmlJS::VM::Value::fromDouble(ConstValuePtr(this)->toInteger(currentEngine()->current))));
+ return Local<Integer>::New(Value::fromVmValue(QQmlJS::VM::Value::fromDouble(ConstValuePtr(this)->toInteger())));
}
Local<Uint32> Value::ToUint32() const
{
- return Local<Uint32>::New(Value::fromVmValue(QQmlJS::VM::Value::fromUInt32(ConstValuePtr(this)->toUInt32(currentEngine()->current))));
+ return Local<Uint32>::New(Value::fromVmValue(QQmlJS::VM::Value::fromUInt32(ConstValuePtr(this)->toUInt32())));
}
Local<Int32> Value::ToInt32() const
{
- return Local<Int32>::New(Value::fromVmValue(QQmlJS::VM::Value::fromInt32(ConstValuePtr(this)->toInt32(currentEngine()->current))));
+ return Local<Int32>::New(Value::fromVmValue(QQmlJS::VM::Value::fromInt32(ConstValuePtr(this)->toInt32())));
}
Local<Uint32> Value::ToArrayIndex() const
int64_t Value::IntegerValue() const
{
- return (int64_t)ConstValuePtr(this)->toInteger(currentEngine()->current);
+ return (int64_t)ConstValuePtr(this)->toInteger();
}
uint32_t Value::Uint32Value() const
{
- return ConstValuePtr(this)->toUInt32(currentEngine()->current);
+ return ConstValuePtr(this)->toUInt32();
}
int32_t Value::Int32Value() const
{
- return ConstValuePtr(this)->toInt32(currentEngine()->current);
+ return ConstValuePtr(this)->toInt32();
}
bool Value::Equals(Handle<Value> that) const
{
- return __qmljs_equal(*ConstValuePtr(this), *ConstValuePtr(&that), currentEngine()->current);
+ return __qmljs_equal(*ConstValuePtr(this), *ConstValuePtr(&that));
}
bool Value::StrictEquals(Handle<Value> that) const
{
- return __qmljs_strict_equal(*ConstValuePtr(this), *ConstValuePtr(&that), currentEngine()->current);
+ return __qmljs_strict_equal(*ConstValuePtr(this), *ConstValuePtr(&that));
}
VM::Value Value::vmValue() const
{
const VM::Value *v = ConstValuePtr(this);
assert(v->isNumber());
- return v->toUInt32(currentEngine()->current);
+ return v->toUInt32();
}
namespace VM {
-int Value::toUInt16(ExecutionContext *ctx) const
+int Value::toUInt16() const
{
if (isConvertibleToInt())
return (ushort)(uint)integerValue();
- double number = __qmljs_to_number(*this, ctx);
+ double number = __qmljs_to_number(*this);
double D16 = 65536.0;
if ((number >= 0 && number < D16))
return (unsigned short)number;
}
-double Value::toInteger(ExecutionContext *ctx) const
+double Value::toInteger() const
{
if (isConvertibleToInt())
return int_32;
- return Value::toInteger(__qmljs_to_number(*this, ctx));
+ return Value::toInteger(__qmljs_to_number(*this));
}
-double Value::toNumber(ExecutionContext *ctx) const
+double Value::toNumber() const
{
- return __qmljs_to_number(*this, ctx);
+ return __qmljs_to_number(*this);
}
bool Value::sameValue(Value other) const {
struct Value;
extern "C" {
-double __qmljs_to_number(const Value &value, ExecutionContext *ctx);
+double __qmljs_to_number(const Value &value);
Q_V4_EXPORT String *__qmljs_convert_to_string(ExecutionContext *ctx, const Value &value);
Object *__qmljs_convert_to_object(ExecutionContext *ctx, const Value &value);
}
static int toInt32(double value);
static unsigned int toUInt32(double value);
- int toUInt16(ExecutionContext *ctx) const;
- int toInt32(ExecutionContext *ctx) const;
- unsigned int toUInt32(ExecutionContext *ctx) const;
+ int toUInt16() const;
+ int toInt32() const;
+ unsigned int toUInt32() const;
Bool toBoolean() const;
- double toInteger(ExecutionContext *ctx) const;
- double toNumber(ExecutionContext *ctx) const;
+ double toInteger() const;
+ double toNumber() const;
String *toString(ExecutionContext *ctx) const;
Object *toObject(ExecutionContext *ctx) const;
ArrayObject *asArrayObject() const;
ErrorObject *asErrorObject() const;
uint asArrayIndex() const;
- uint asArrayLength(ExecutionContext *ctx, bool *ok) const;
+ uint asArrayLength(bool *ok) const;
Value property(ExecutionContext *ctx, String *name) const;
return __qmljs_convert_to_object(ctx, *this);
}
-inline int Value::toInt32(ExecutionContext *ctx) const
+inline int Value::toInt32() const
{
if (isConvertibleToInt())
return int_32;
if (isDouble())
d = dbl;
else
- d = __qmljs_to_number(*this, ctx);
+ d = __qmljs_to_number(*this);
const double D32 = 4294967296.0;
const double D31 = D32 / 2.0;
if ((d >= -D31 && d < D31))
return static_cast<int>(d);
- return Value::toInt32(__qmljs_to_number(*this, ctx));
+ return Value::toInt32(__qmljs_to_number(*this));
}
-inline unsigned int Value::toUInt32(ExecutionContext *ctx) const {
+inline unsigned int Value::toUInt32() const
+{
if (isConvertibleToInt())
return (unsigned) int_32;
double d;
if (isDouble())
d = dbl;
else
- d = __qmljs_to_number(*this, ctx);
+ d = __qmljs_to_number(*this);
const double D32 = 4294967296.0;
if (dbl >= 0 && dbl < D32)
return idx;
}
-inline uint Value::asArrayLength(ExecutionContext *ctx, bool *ok) const
+inline uint Value::asArrayLength(bool *ok) const
{
*ok = true;
if (isConvertibleToInt() && int_32 >= 0)
if (isString())
return stringValue()->toUInt(ok);
- uint idx = toUInt32(ctx);
- double d = toNumber(ctx);
+ uint idx = toUInt32();
+ double d = toNumber();
if (d != idx) {
*ok = false;
return UINT_MAX;