assert(!runtimeStrings);
assert(data);
- runtimeStrings = (QV4::String**)malloc(data->stringTableSize * sizeof(QV4::String*));
+ runtimeStrings = (QV4::SafeString *)malloc(data->stringTableSize * sizeof(QV4::SafeString));
for (int i = 0; i < data->stringTableSize; ++i)
runtimeStrings[i] = engine->newIdentifier(data->stringAt(i));
l->classList[i] = 0;
l->level = -1;
l->index = UINT_MAX;
- l->name = runtimeStrings[compiledLookups[i].nameIndex];
+ l->name = runtimeStrings[compiledLookups[i].nameIndex].asString();
}
}
const CompiledData::JSClassMember *member = data->jsClassAt(i, &memberCount);
QV4::InternalClass *klass = engine->objectClass;
for (int j = 0; j < memberCount; ++j, ++member)
- klass = klass->addMember(runtimeStrings[member->nameOffset], member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
+ klass = klass->addMember(runtimeStrings[member->nameOffset].asString(), member->isAccessor ? QV4::Attr_Accessor : QV4::Attr_Data);
runtimeClasses[i] = klass;
}
void CompilationUnit::markObjects()
{
for (int i = 0; i < data->stringTableSize; ++i)
- runtimeStrings[i]->mark();
+ runtimeStrings[i].mark();
for (int i = 0; i < data->regexpTableSize; ++i)
runtimeRegularExpressions[i].mark();
for (int i = 0; i < runtimeFunctions.count(); ++i)
QString fileName() const { return data->stringAt(data->sourceFileIndex); }
- QV4::String **runtimeStrings; // Array
+ QV4::SafeString *runtimeStrings; // Array
QV4::Lookup *runtimeLookups;
QV4::Value *runtimeRegularExpressions;
QV4::InternalClass **runtimeClasses;
{
loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, runtimeStrings)), reg);
const int id = _isel->registerString(string);
- return Pointer(reg, id * sizeof(QV4::String*));
+ return Pointer(reg, id * sizeof(QV4::SafeString));
+}
+
+void Assembler::loadStringRef(RegisterID reg, const QString &string)
+{
+ loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, runtimeStrings)), reg);
+ const int id = _isel->registerString(string);
+ addPtr(TrustedImmPtr(id * sizeof(QV4::SafeString)), reg);
}
template <typename Result, typename Source>
typedef void *(*MiddleOfFunctionEntryPoint(ExecutionContext *, void *localsPtr));
static void *tryWrapper(ExecutionContext *context, void *localsPtr, MiddleOfFunctionEntryPoint tryBody, MiddleOfFunctionEntryPoint catchBody,
- QV4::String *exceptionVarName, ValueRef exceptionVar)
+ QV4::StringRef exceptionVarName, ValueRef exceptionVar)
{
exceptionVar = Value::undefinedValue();
void *addressToContinueAt = 0;
_as->loadPtr(srcAddr, Assembler::ReturnValueRegister);
Pointer destAddr = _as->loadTempAddress(Assembler::ScratchRegister, targetTemp);
#if QT_POINTER_SIZE == 8
- _as->or64(Assembler::TrustedImm64(quint64(QV4::Value::Managed_Type) << QV4::Value::Tag_Shift),
- Assembler::ReturnValueRegister);
_as->store64(Assembler::ReturnValueRegister, destAddr);
#else
_as->store32(Assembler::ReturnValueRegister, destAddr);
Pointer loadTempAddress(RegisterID reg, V4IR::Temp *t);
Pointer loadStringAddress(RegisterID reg, const QString &string);
+ void loadStringRef(RegisterID reg, const QString &string);
Pointer stackSlotPointer(V4IR::Temp *t) const
{
Q_ASSERT(t->kind == V4IR::Temp::StackSlot);
void loadArgumentInRegister(PointerToString temp, RegisterID dest, int argumentNumber)
{
Q_UNUSED(argumentNumber);
- Pointer addr = loadStringAddress(dest, temp.string);
- loadPtr(addr, dest);
+ loadStringRef(dest, temp.string);
}
void loadArgumentInRegister(Reference temp, RegisterID dest, int argumentNumber)
void loadArgumentOnStack(PointerToString temp, int argumentNumber)
{
Q_UNUSED(argumentNumber);
- Pointer ptr = loadStringAddress(ScratchRegister, temp.string);
- loadPtr(ptr, ScratchRegister);
+ loadStringRef(ScratchRegister, temp.string);
poke(ScratchRegister, StackSlot);
}
-void ExecutionContext::createMutableBinding(String *name, bool deletable)
+void ExecutionContext::createMutableBinding(const StringRef name, bool deletable)
{
Scope scope(this);
- ScopedString n(scope, name);
// find the right context to create the binding on
Object *activation = engine->globalObject;
ctx = ctx->outer;
}
- if (activation->__hasProperty__(n))
+ if (activation->__hasProperty__(name))
return;
Property desc = Property::fromValue(Value::undefinedValue());
PropertyAttributes attrs(Attr_Data);
attrs.setConfigurable(deletable);
- activation->__defineOwnProperty__(this, n, desc, attrs);
+ activation->__defineOwnProperty__(this, name, desc, attrs);
}
String * const *ExecutionContext::formals() const
}
}
-void ExecutionContext::setProperty(String *name, const ValueRef value)
+void ExecutionContext::setProperty(const StringRef name, const ValueRef value)
{
Scope scope(this);
- ScopedString n(scope, name);
for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) {
if (ctx->type == Type_WithContext) {
Object *w = static_cast<WithContext *>(ctx)->withObject;
- if (w->__hasProperty__(n)) {
- w->put(n, value);
+ if (w->__hasProperty__(name)) {
+ w->put(name, value);
return;
}
} else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) {
activation = static_cast<GlobalContext *>(ctx)->global;
}
- if (activation && (ctx->type == Type_QmlContext || activation->__hasProperty__(n))) {
- activation->put(n, value);
+ if (activation && (ctx->type == Type_QmlContext || activation->__hasProperty__(name))) {
+ activation->put(name, value);
return;
}
}
}
if (strictMode || name->isEqualTo(engine->id_this)) {
- Scoped<String> n(scope, name);
+ ScopedValue n(scope, name.asReturnedValue());
throwReferenceError(n);
}
- engine->globalObject->put(n, value);
+ engine->globalObject->put(name, value);
}
-ReturnedValue ExecutionContext::getProperty(String *name)
+ReturnedValue ExecutionContext::getProperty(const StringRef name)
{
Scope scope(this);
ScopedValue v(scope);
- ScopedString n(scope, name);
- n->makeIdentifier();
+ name->makeIdentifier();
if (name->isEqualTo(engine->id_this))
return thisObject.asReturnedValue();
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
- v = w->get(n, &hasProperty);
+ v = w->get(name, &hasProperty);
if (hasProperty) {
return v.asReturnedValue();
}
}
if (c->activation) {
bool hasProperty = false;
- v = c->activation->get(n, &hasProperty);
+ v = c->activation->get(name, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
- v = g->global->get(n, &hasProperty);
+ v = g->global->get(name, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
}
+ ScopedValue n(scope, name.asReturnedValue());
throwReferenceError(n);
return 0;
}
-ReturnedValue ExecutionContext::getPropertyNoThrow(String *name)
+ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name)
{
Scope scope(this);
ScopedValue v(scope);
- ScopedString n(scope, name);
- n->makeIdentifier();
+ name->makeIdentifier();
- if (n->isEqualTo(engine->id_this))
+ if (name->isEqualTo(engine->id_this))
return thisObject.asReturnedValue();
bool hasWith = false;
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
- v = w->get(n, &hasProperty);
+ v = w->get(name, &hasProperty);
if (hasProperty) {
return v.asReturnedValue();
}
}
if (c->activation) {
bool hasProperty = false;
- v = c->activation->get(n, &hasProperty);
+ v = c->activation->get(name, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
- v = g->global->get(n, &hasProperty);
+ v = g->global->get(name, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
return Value::undefinedValue().asReturnedValue();
}
-ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base)
+ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, Object **base)
{
Scope scope(this);
ScopedValue v(scope);
- ScopedString n(scope, name);
*base = 0;
- n->makeIdentifier();
+ name->makeIdentifier();
- if (n->isEqualTo(engine->id_this))
+ if (name->isEqualTo(engine->id_this))
return thisObject.asReturnedValue();
bool hasWith = false;
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
- v = w->get(n, &hasProperty);
+ v = w->get(name, &hasProperty);
if (hasProperty) {
*base = w;
return v.asReturnedValue();
}
if (c->activation) {
bool hasProperty = false;
- v = c->activation->get(n, &hasProperty);
+ v = c->activation->get(name, &hasProperty);
if (hasProperty) {
if (ctx->type == Type_QmlContext)
*base = c->activation;
else if (ctx->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
- v = g->global->get(n, &hasProperty);
+ v = g->global->get(name, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
}
+ ScopedValue n(scope, name.asReturnedValue());
throwReferenceError(n);
return 0;
}
ExecutionContext *parent;
ExecutionContext *outer;
Lookup *lookups;
- String **runtimeStrings;
+ SafeString *runtimeStrings;
CompiledData::CompilationUnit *compilationUnit;
const CompiledData::Function *compiledFunction;
ExecutionContext *next; // used in the GC
String * const *variables() const;
unsigned int variableCount() const;
- void createMutableBinding(String *name, bool deletable);
+ void createMutableBinding(const StringRef name, bool deletable);
void Q_NORETURN throwError(const QV4::ValueRef value);
void Q_NORETURN throwError(const QString &message);
void Q_NORETURN throwURIError(Value msg);
void Q_NORETURN throwUnimplemented(const QString &message);
- void setProperty(String *name, const ValueRef value);
- ReturnedValue getProperty(String *name);
- ReturnedValue getPropertyNoThrow(String *name);
- ReturnedValue getPropertyAndBase(String *name, Object **base);
+ void setProperty(const StringRef name, const ValueRef value);
+ ReturnedValue getProperty(const StringRef name);
+ ReturnedValue getPropertyNoThrow(const StringRef name);
+ ReturnedValue getPropertyAndBase(const StringRef name, Object **base);
bool deleteProperty(const StringRef name);
void mark();
, codeData(0)
, codeSize(_codeSize)
{
- name = compilationUnit->runtimeStrings[compiledFunction->nameIndex];
+ name = compilationUnit->runtimeStrings[compiledFunction->nameIndex].asString();
formals.resize(compiledFunction->nFormals);
const quint32 *formalsIndices = compiledFunction->formalsTable();
CompiledData::CompilationUnit * const oldCompilationUnit = ctx->compilationUnit;
const CompiledData::Function * const oldCompiledFunction = ctx->compiledFunction;
- String ** const oldRuntimeStrings = ctx->runtimeStrings;
+ SafeString * const oldRuntimeStrings = ctx->runtimeStrings;
ctx->compilationUnit = function->compilationUnit;
ctx->compiledFunction = function->compiledFunction;
ctx->runtimeStrings = function->compilationUnit->runtimeStrings;
ReturnedValue __qmljs_delete_subscript(ExecutionContext *ctx, const ValueRef base, const ValueRef index)
{
- if (Object *o = base->asObject()) {
+ Scope scope(ctx);
+ ScopedObject o(scope, base);
+ if (o) {
uint n = index->asArrayIndex();
if (n < UINT_MAX) {
return Value::fromBoolean(o->deleteIndexedProperty(n)).asReturnedValue();
}
}
- String *name = index->toString(ctx);
+ ScopedString name(scope, index->toString(ctx));
return __qmljs_delete_member(ctx, base, name);
}
-ReturnedValue __qmljs_delete_member(ExecutionContext *ctx, const ValueRef base, String *name)
+ReturnedValue __qmljs_delete_member(ExecutionContext *ctx, const ValueRef base, const StringRef name)
{
Scope scope(ctx);
ScopedObject obj(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- return Encode(obj->deleteProperty(n));
+ return Encode(obj->deleteProperty(name));
}
-ReturnedValue __qmljs_delete_name(ExecutionContext *ctx, String *name)
+ReturnedValue __qmljs_delete_name(ExecutionContext *ctx, const StringRef name)
{
Scope scope(ctx);
- ScopedString n(scope, name);
- return Encode(ctx->deleteProperty(n));
+ return Encode(ctx->deleteProperty(name));
}
QV4::ReturnedValue __qmljs_add_helper(ExecutionContext *ctx, const ValueRef left, const ValueRef right)
return Value::fromBoolean(r).asReturnedValue();
}
-static void inplaceBitOp(ExecutionContext *ctx, String *name, const ValueRef value, BinOp op)
+static void inplaceBitOp(ExecutionContext *ctx, const StringRef name, const ValueRef value, BinOp op)
{
Scope scope(ctx);
ScopedValue lhs(scope, ctx->getProperty(name));
}
-void __qmljs_inplace_bit_and_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_bit_and_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_bit_and);
}
-void __qmljs_inplace_bit_or_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_bit_or_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_bit_or);
}
-void __qmljs_inplace_bit_xor_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_bit_xor_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_bit_xor);
}
-void __qmljs_inplace_add_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_add_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
Scope scope(ctx);
ScopedValue lhs(scope, ctx->getProperty(name));
ctx->setProperty(name, result);
}
-void __qmljs_inplace_sub_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_sub_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_sub);
}
-void __qmljs_inplace_mul_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_mul_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_mul);
}
-void __qmljs_inplace_div_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_div_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_div);
}
-void __qmljs_inplace_mod_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_mod_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_mod);
}
-void __qmljs_inplace_shl_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_shl_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_shl);
}
-void __qmljs_inplace_shr_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_shr_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_shr);
}
-void __qmljs_inplace_ushr_name(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_inplace_ushr_name(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
inplaceBitOp(ctx, name, value, __qmljs_ushr);
}
obj->inplaceBinOpValue(ctx, __qmljs_ushr, index, rhs);
}
-void __qmljs_inplace_bit_and_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_bit_and_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_bit_and, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_bit_and, name, rhs);
}
-void __qmljs_inplace_bit_or_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_bit_or_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_bit_or, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_bit_or, name, rhs);
}
-void __qmljs_inplace_bit_xor_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_bit_xor_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_bit_xor, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_bit_xor, name, rhs);
}
-void __qmljs_inplace_add_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_add_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_add, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_add, name, rhs);
}
-void __qmljs_inplace_sub_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_sub_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_sub, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_sub, name, rhs);
}
-void __qmljs_inplace_mul_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_mul_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_mul, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_mul, name, rhs);
}
-void __qmljs_inplace_div_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_div_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_div, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_div, name, rhs);
}
-void __qmljs_inplace_mod_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_mod_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_mod, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_mod, name, rhs);
}
-void __qmljs_inplace_shl_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_shl_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_shl, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_shl, name, rhs);
}
-void __qmljs_inplace_shr_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_shr_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_shr, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_shr, name, rhs);
}
-void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const ValueRef base, String *name, const ValueRef rhs)
+void __qmljs_inplace_ushr_member(ExecutionContext *ctx, const ValueRef base, const StringRef name, const ValueRef rhs)
{
Scope scope(ctx);
ScopedObject o(scope, base->toObject(ctx));
- ScopedString n(scope, name);
- o->inplaceBinOp(ctx, __qmljs_ushr, n, rhs);
+ o->inplaceBinOp(ctx, __qmljs_ushr, name, rhs);
}
double __qmljs_string_to_number(const QString &string)
} // switch
}
-void __qmljs_set_property(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef value)
+void __qmljs_set_property(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef value)
{
Scope scope(ctx);
ScopedObject o(scope, object->toObject(ctx));
- ScopedString n(scope, name);
- o->put(n, value);
+ o->put(name, value);
}
ReturnedValue __qmljs_get_element(ExecutionContext *ctx, const ValueRef object, const ValueRef index)
}
-void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const ValueRef value)
+void __qmljs_set_activation_property(ExecutionContext *ctx, const StringRef name, const ValueRef value)
{
ctx->setProperty(name, value);
}
-ReturnedValue __qmljs_get_property(ExecutionContext *ctx, const ValueRef object, String *n)
+ReturnedValue __qmljs_get_property(ExecutionContext *ctx, const ValueRef object, const StringRef name)
{
Scope scope(ctx);
- ScopedString name(scope, n);
Scoped<Object> o(scope, object);
if (o)
return o->get(name);
}
-ReturnedValue __qmljs_get_activation_property(ExecutionContext *ctx, String *name)
+ReturnedValue __qmljs_get_activation_property(ExecutionContext *ctx, const StringRef name)
{
return ctx->getProperty(name);
}
}
-ReturnedValue __qmljs_call_activation_property(ExecutionContext *context, String *name, CallDataRef callData)
+ReturnedValue __qmljs_call_activation_property(ExecutionContext *context, const StringRef name, CallDataRef callData)
{
Q_ASSERT(callData->thisObject.isUndefined());
Scope scope(context);
return o->call(callData);
}
-ReturnedValue __qmljs_call_property(ExecutionContext *context, String *n, CallDataRef callData)
+ReturnedValue __qmljs_call_property(ExecutionContext *context, const StringRef name, CallDataRef callData)
{
Scope scope(context);
- ScopedString name(scope, n);
Scoped<Object> baseObject(scope, callData->thisObject);
if (!baseObject) {
Q_ASSERT(!callData->thisObject.isEmpty());
}
-ReturnedValue __qmljs_construct_activation_property(ExecutionContext *context, String *name, CallDataRef callData)
+ReturnedValue __qmljs_construct_activation_property(ExecutionContext *context, const StringRef name, CallDataRef callData)
{
Scope scope(context);
ScopedValue func(scope, context->getProperty(name));
return f->construct(callData);
}
-ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueRef base, String *n, CallDataRef callData)
+ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueRef base, const StringRef name, CallDataRef callData)
{
Scope scope(context);
ScopedObject thisObject(scope, base->toObject(context));
- ScopedString name(scope, n);
Scoped<Object> f(scope, thisObject->get(name));
if (!f)
return Value::fromString(res).asReturnedValue();
}
-QV4::ReturnedValue __qmljs_builtin_typeof_name(ExecutionContext *context, String *name)
+QV4::ReturnedValue __qmljs_builtin_typeof_name(ExecutionContext *context, const StringRef name)
{
Scope scope(context);
ScopedValue prop(scope, context->getPropertyNoThrow(name));
return __qmljs_builtin_typeof(context, prop);
}
-QV4::ReturnedValue __qmljs_builtin_typeof_member(ExecutionContext *context, const ValueRef base, String *n)
+QV4::ReturnedValue __qmljs_builtin_typeof_member(ExecutionContext *context, const ValueRef base, const StringRef name)
{
Scope scope(context);
ScopedObject obj(scope, base->toObject(context));
- ScopedString name(scope, n);
ScopedValue prop(scope, obj->get(name));
return __qmljs_builtin_typeof(context, prop);
}
return ctx->newWithContext(obj);
}
-ExecutionContext *__qmljs_builtin_push_catch_scope(String *exceptionVarName, const ValueRef exceptionValue, ExecutionContext *ctx)
+ExecutionContext *__qmljs_builtin_push_catch_scope(const StringRef exceptionVarName, const ValueRef exceptionValue, ExecutionContext *ctx)
{
- return ctx->newCatchContext(exceptionVarName, *exceptionValue);
+ return ctx->newCatchContext(exceptionVarName.getPointer(), *exceptionValue);
}
ExecutionContext *__qmljs_builtin_pop_scope(ExecutionContext *ctx)
return ctx->engine->popContext();
}
-void __qmljs_builtin_declare_var(ExecutionContext *ctx, bool deletable, String *name)
+void __qmljs_builtin_declare_var(ExecutionContext *ctx, bool deletable, const StringRef name)
{
ctx->createMutableBinding(name, deletable);
}
-void __qmljs_builtin_define_property(ExecutionContext *ctx, const ValueRef object, String *name, ValueRef val)
+void __qmljs_builtin_define_property(ExecutionContext *ctx, const ValueRef object, const StringRef name, ValueRef val)
{
Scope scope(ctx);
ScopedObject o(scope, object->asObject());
assert(o);
uint idx = name->asArrayIndex();
- Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx) : o->insertMember(ScopedString(scope, name), Attr_Data);
+ Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx) : o->insertMember(name, Attr_Data);
pd->value = val ? *val : Value::undefinedValue();
}
return a.asReturnedValue();
}
-void __qmljs_builtin_define_getter_setter(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef getter, const ValueRef setter)
+void __qmljs_builtin_define_getter_setter(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef getter, const ValueRef setter)
{
Scope scope(ctx);
ScopedObject o(scope, object->asObject());
Q_ASSERT(!!o);
uint idx = name->asArrayIndex();
- Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx, Attr_Accessor) : o->insertMember(ScopedString(scope, name), Attr_Accessor);
+ Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx, Attr_Accessor) : o->insertMember(name, Attr_Accessor);
pd->setGetter(getter ? getter->asFunctionObject() : 0);
pd->setSetter(setter ? setter->asFunctionObject() : 0);
}
struct InternalClass;
// context
-QV4::ReturnedValue __qmljs_call_activation_property(QV4::ExecutionContext *, QV4::String *name, CallDataRef callData);
-QV4::ReturnedValue __qmljs_call_property(QV4::ExecutionContext *context, QV4::String *name, CallDataRef callData);
+QV4::ReturnedValue __qmljs_call_activation_property(QV4::ExecutionContext *, const QV4::StringRef name, CallDataRef callData);
+QV4::ReturnedValue __qmljs_call_property(QV4::ExecutionContext *context, const QV4::StringRef name, CallDataRef callData);
QV4::ReturnedValue __qmljs_call_property_lookup(ExecutionContext *context, uint index, CallDataRef callData);
QV4::ReturnedValue __qmljs_call_element(ExecutionContext *context, const ValueRef index, CallDataRef callData);
QV4::ReturnedValue __qmljs_call_value(QV4::ExecutionContext *context, const QV4::ValueRef func, CallDataRef callData);
-QV4::ReturnedValue __qmljs_construct_activation_property(QV4::ExecutionContext *, QV4::String *name, CallDataRef callData);
-QV4::ReturnedValue __qmljs_construct_property(QV4::ExecutionContext *context, const QV4::ValueRef base, QV4::String *name, CallDataRef callData);
+QV4::ReturnedValue __qmljs_construct_activation_property(QV4::ExecutionContext *, const QV4::StringRef name, CallDataRef callData);
+QV4::ReturnedValue __qmljs_construct_property(QV4::ExecutionContext *context, const QV4::ValueRef base, const QV4::StringRef name, CallDataRef callData);
QV4::ReturnedValue __qmljs_construct_value(QV4::ExecutionContext *context, const QV4::ValueRef func, CallDataRef callData);
QV4::ReturnedValue __qmljs_builtin_typeof(QV4::ExecutionContext *ctx, const QV4::ValueRef val);
-QV4::ReturnedValue __qmljs_builtin_typeof_name(QV4::ExecutionContext *context, QV4::String *name);
-QV4::ReturnedValue __qmljs_builtin_typeof_member(QV4::ExecutionContext* context, const QV4::ValueRef base, QV4::String *name);
+QV4::ReturnedValue __qmljs_builtin_typeof_name(QV4::ExecutionContext *context, const QV4::StringRef name);
+QV4::ReturnedValue __qmljs_builtin_typeof_member(QV4::ExecutionContext* context, const QV4::ValueRef base, const QV4::StringRef name);
QV4::ReturnedValue __qmljs_builtin_typeof_element(QV4::ExecutionContext* context, const QV4::ValueRef base, const QV4::ValueRef index);
void Q_NORETURN __qmljs_builtin_rethrow(QV4::ExecutionContext *context);
QV4::ExecutionContext *__qmljs_builtin_push_with_scope(const QV4::ValueRef o, QV4::ExecutionContext *ctx);
-QV4::ExecutionContext *__qmljs_builtin_push_catch_scope(QV4::String *exceptionVarName, const QV4::ValueRef exceptionValue, QV4::ExecutionContext *ctx);
+QV4::ExecutionContext *__qmljs_builtin_push_catch_scope(const QV4::StringRef exceptionVarName, const QV4::ValueRef exceptionValue, QV4::ExecutionContext *ctx);
QV4::ExecutionContext *__qmljs_builtin_pop_scope(QV4::ExecutionContext *ctx);
-void __qmljs_builtin_declare_var(QV4::ExecutionContext *ctx, bool deletable, QV4::String *name);
-void __qmljs_builtin_define_property(QV4::ExecutionContext *ctx, const QV4::ValueRef object, QV4::String *name, QV4::ValueRef val);
+void __qmljs_builtin_declare_var(QV4::ExecutionContext *ctx, bool deletable, const QV4::StringRef name);
+void __qmljs_builtin_define_property(QV4::ExecutionContext *ctx, const QV4::ValueRef object, const QV4::StringRef name, QV4::ValueRef val);
QV4::ReturnedValue __qmljs_builtin_define_array(QV4::ExecutionContext *ctx, QV4::Value *values, uint length);
-void __qmljs_builtin_define_getter_setter(QV4::ExecutionContext *ctx, const QV4::ValueRef object, QV4::String *name, const QV4::ValueRef getter, const QV4::ValueRef setter);
+void __qmljs_builtin_define_getter_setter(QV4::ExecutionContext *ctx, const QV4::ValueRef object, const QV4::StringRef name, const QV4::ValueRef getter, const QV4::ValueRef setter);
QV4::ReturnedValue __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId);
QV4::ReturnedValue __qmljs_builtin_setup_arguments_object(ExecutionContext *ctx);
// objects
Q_QML_EXPORT ReturnedValue __qmljs_object_default_value(QV4::Object *object, int typeHint);
-void __qmljs_set_activation_property(QV4::ExecutionContext *ctx, QV4::String *name, const QV4::ValueRef value);
-void __qmljs_set_property(QV4::ExecutionContext *ctx, const QV4::ValueRef object, QV4::String *name, const QV4::ValueRef value);
-QV4::ReturnedValue __qmljs_get_property(QV4::ExecutionContext *ctx, const QV4::ValueRef object, QV4::String *name);
-QV4::ReturnedValue __qmljs_get_activation_property(QV4::ExecutionContext *ctx, QV4::String *name);
+void __qmljs_set_activation_property(QV4::ExecutionContext *ctx, const QV4::StringRef name, const QV4::ValueRef value);
+void __qmljs_set_property(QV4::ExecutionContext *ctx, const QV4::ValueRef object, const QV4::StringRef name, const QV4::ValueRef value);
+QV4::ReturnedValue __qmljs_get_property(QV4::ExecutionContext *ctx, const QV4::ValueRef object, const QV4::StringRef name);
+QV4::ReturnedValue __qmljs_get_activation_property(QV4::ExecutionContext *ctx, const QV4::StringRef name);
ReturnedValue __qmljs_call_global_lookup(QV4::ExecutionContext *context, uint index, CallDataRef callData);
QV4::ReturnedValue __qmljs_construct_global_lookup(QV4::ExecutionContext *context, uint index, CallDataRef callData);
Q_QML_EXPORT unsigned __qmljs_double_to_uint32(const double &d);
QV4::ReturnedValue __qmljs_delete_subscript(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::ValueRef index);
-ReturnedValue __qmljs_delete_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name);
-ReturnedValue __qmljs_delete_name(QV4::ExecutionContext *ctx, QV4::String *name);
+ReturnedValue __qmljs_delete_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name);
+ReturnedValue __qmljs_delete_name(QV4::ExecutionContext *ctx, const QV4::StringRef name);
void Q_NORETURN __qmljs_throw(QV4::ExecutionContext*, const QV4::ValueRef value);
QV4::ReturnedValue __qmljs_add_helper(QV4::ExecutionContext *ctx, const QV4::ValueRef left, const QV4::ValueRef right);
-typedef void (*InplaceBinOpName)(QV4::ExecutionContext *ctx, QV4::String *name, const QV4::ValueRef value);
-void __qmljs_inplace_bit_and_name(QV4::ExecutionContext *ctx, QV4::String *name, const QV4::ValueRef value);
-void __qmljs_inplace_bit_or_name(QV4::ExecutionContext *ctx, QV4::String *name, const QV4::ValueRef value);
-void __qmljs_inplace_bit_xor_name(QV4::ExecutionContext *ctx, QV4::String *name, const QV4::ValueRef value);
-void __qmljs_inplace_add_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_sub_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_mul_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_div_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_mod_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_shl_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_shr_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
-void __qmljs_inplace_ushr_name(QV4::ExecutionContext *ctx, QV4::String *name, const ValueRef value);
+typedef void (*InplaceBinOpName)(QV4::ExecutionContext *ctx, const QV4::StringRef name, const QV4::ValueRef value);
+void __qmljs_inplace_bit_and_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const QV4::ValueRef value);
+void __qmljs_inplace_bit_or_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const QV4::ValueRef value);
+void __qmljs_inplace_bit_xor_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const QV4::ValueRef value);
+void __qmljs_inplace_add_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_sub_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_mul_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_div_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_mod_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_shl_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_shr_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
+void __qmljs_inplace_ushr_name(QV4::ExecutionContext *ctx, const QV4::StringRef name, const ValueRef value);
typedef void (*InplaceBinOpElement)(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::ValueRef index, const QV4::ValueRef rhs);
void __qmljs_inplace_bit_and_element(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::ValueRef index, const QV4::ValueRef rhs);
void __qmljs_inplace_shr_element(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::ValueRef index, const QV4::ValueRef rhs);
void __qmljs_inplace_ushr_element(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::ValueRef index, const QV4::ValueRef rhs);
-typedef void (*InplaceBinOpMember)(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_bit_and_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_bit_or_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_bit_xor_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_add_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_sub_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_mul_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_div_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_mod_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_shl_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_shr_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
-void __qmljs_inplace_ushr_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, QV4::String *name, const QV4::ValueRef rhs);
+typedef void (*InplaceBinOpMember)(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_bit_and_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_bit_or_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_bit_xor_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_add_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_sub_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_mul_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_div_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_mod_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_shl_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_shr_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
+void __qmljs_inplace_ushr_member(QV4::ExecutionContext *ctx, const QV4::ValueRef base, const QV4::StringRef name, const QV4::ValueRef rhs);
typedef QV4::Bool (*CmpOp)(const QV4::ValueRef left, const QV4::ValueRef right);
QV4::Bool __qmljs_cmp_gt(const QV4::ValueRef l, const QV4::ValueRef r);
Lookup *oldLookups = scope->lookups;
CompiledData::CompilationUnit * const oldCompilationUnit = scope->compilationUnit;
const CompiledData::Function * const oldCompiledFunction = scope->compiledFunction;
- String ** const oldRuntimeStrings = scope->runtimeStrings;
+ SafeString * const oldRuntimeStrings = scope->runtimeStrings;
scope->strictMode = vmFunction->isStrict();
scope->lookups = vmFunction->compilationUnit->runtimeLookups;
}
#endif
- QV4::String ** const runtimeStrings = context->runtimeStrings;
+ QV4::SafeString * const runtimeStrings = context->runtimeStrings;
context->interpreterInstructionPointer = &code;
#ifdef MOTH_THREADED_INTERPRETER