#define QMLJS_ENVIRONMENT_H
#include "qv4global_p.h"
-#include "qv4value_p.h"
+#include "qv4scopedvalue_p.h"
#include "qv4managed_p.h"
#include "qv4engine_p.h"
bool needsOwnArguments() const;
};
+inline ReturnedValue CallContext::argument(int i) {
+ return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
+}
+
struct GlobalContext : public ExecutionContext
{
GlobalContext(ExecutionEngine *engine);
}
};
+inline Scope::Scope(ExecutionContext *ctx)
+ : engine(ctx->engine)
+#ifndef QT_NO_DEBUG
+ , size(0)
+#endif
+{
+ mark = engine->jsStackTop;
+}
+
/* Function *f, int argc */
#define requiredMemoryForExecutionContect(f, argc) \
sizeof(CallContext) + sizeof(Value) * (f->varCount + qMax((uint)argc, f->formalParameterCount)) + sizeof(CallData)
}
template<>
-inline ReturnedValue value_convert<Object>(ExecutionContext *ctx, const Value &v)
+inline ReturnedValue value_convert<Object>(ExecutionEngine *e, const Value &v)
{
- return v.toObject(ctx)->asReturnedValue();
+ return v.toObject(e->currentContext())->asReturnedValue();
}
}
#include "qv4value_inl_p.h"
#include "qv4math_p.h"
#include "qv4scopedvalue_p.h"
+#include "qv4context_p.h"
#include <QtCore/QString>
#include <QtCore/qnumeric.h>
#ifndef QV4SCOPEDVALUE_P_H
#define QV4SCOPEDVALUE_P_H
-#include "qv4context_p.h"
+#include "qv4engine_p.h"
#include "qv4value_p.h"
QT_BEGIN_NAMESPACE
struct ScopedValue;
struct Scope {
- explicit Scope(ExecutionContext *ctx)
- : engine(ctx->engine)
-#ifndef QT_NO_DEBUG
- , size(0)
-#endif
- {
- mark = engine->jsStackTop;
- }
-
+ inline explicit Scope(ExecutionContext *ctx);
explicit Scope(ExecutionEngine *e)
: engine(e)
#ifndef QT_NO_DEBUG
Scoped(const Scope &scope, const Value &v, _Convert)
{
ptr = scope.engine->jsStackTop++;
- ptr->val = value_convert<T>(scope.engine->currentContext(), v);
+ ptr->val = value_convert<T>(scope.engine, v);
#ifndef QT_NO_DEBUG
++scope.size;
#endif
Scoped(const Scope &scope, const ReturnedValue &v, _Convert)
{
ptr = scope.engine->jsStackTop++;
- ptr->val = value_convert<T>(scope.engine->currentContext(), QV4::Value::fromReturnedValue(v));
+ ptr->val = value_convert<T>(scope.engine, QV4::Value::fromReturnedValue(v));
#ifndef QT_NO_DEBUG
++scope.size;
#endif
return operator=(QV4::Value::fromManaged(obj->getPointer()).asReturnedValue());
}
-inline ReturnedValue CallContext::argument(int i) {
- return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
-}
-
}
}
template<>
-inline ReturnedValue value_convert<String>(ExecutionContext *ctx, const Value &v)
+inline ReturnedValue value_convert<String>(ExecutionEngine *e, const Value &v)
{
- return v.toString(ctx)->asReturnedValue();
+ return v.toString(e)->asReturnedValue();
}
}
return std::signbit(number) ? -v : v;
}
+String *Value::toString(ExecutionEngine *e) const
+{
+ return toString(e->currentContext());
+}
+
String *Value::toString(ExecutionContext *ctx) const
{
if (isString())
double toNumberImpl() const;
QString toQStringNoThrow() const;
QString toQString() const;
+ String *toString(ExecutionEngine *e) const;
String *toString(ExecutionContext *ctx) const;
Object *toObject(ExecutionContext *ctx) const;
}
template<typename T>
-ReturnedValue value_convert(ExecutionContext *ctx, const Value &v);
+ReturnedValue value_convert(ExecutionEngine *e, const Value &v);