2012-11-17 20:54:26 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2015-01-28 11:55:39 +00:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing/
|
2012-11-17 20:54:26 +00:00
|
|
|
**
|
2013-06-24 11:50:51 +00:00
|
|
|
** This file is part of the QtQml module of the Qt Toolkit.
|
2012-11-17 20:54:26 +00:00
|
|
|
**
|
2014-08-22 06:13:59 +00:00
|
|
|
** $QT_BEGIN_LICENSE:LGPL21$
|
2012-11-17 20:54:26 +00:00
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at http://www.qt.io/contact-us.
|
2012-11-17 20:54:26 +00:00
|
|
|
**
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-08-22 06:13:59 +00:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-11-17 20:54:26 +00:00
|
|
|
**
|
2015-01-28 11:55:39 +00:00
|
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2012-11-17 20:54:26 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
2013-03-18 10:03:51 +00:00
|
|
|
#ifndef QV4ENGINE_H
|
|
|
|
#define QV4ENGINE_H
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-04-15 09:50:16 +00:00
|
|
|
#include "qv4global_p.h"
|
2013-08-08 07:20:52 +00:00
|
|
|
#include "private/qv4isel_p.h"
|
2014-07-25 15:44:14 +00:00
|
|
|
#include "qv4managed_p.h"
|
2014-11-18 16:35:48 +00:00
|
|
|
#include "qv4context_p.h"
|
2013-05-14 00:01:04 +00:00
|
|
|
#include <private/qintrusivelist_p.h>
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-04-19 09:47:50 +00:00
|
|
|
namespace WTF {
|
|
|
|
class BumpPointerAllocator;
|
2013-09-03 10:40:07 +00:00
|
|
|
class PageAllocation;
|
2013-04-19 09:47:50 +00:00
|
|
|
}
|
2013-01-14 15:53:43 +00:00
|
|
|
|
2013-01-31 09:00:06 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2013-06-04 14:00:13 +00:00
|
|
|
class QV8Engine;
|
2013-10-17 06:56:51 +00:00
|
|
|
class QQmlError;
|
2014-12-30 14:31:09 +00:00
|
|
|
class QJSEngine;
|
2014-12-30 15:38:20 +00:00
|
|
|
class QQmlEngine;
|
2013-04-17 16:17:30 +00:00
|
|
|
|
2013-07-24 08:29:04 +00:00
|
|
|
namespace QV4 {
|
2012-11-29 13:41:26 +00:00
|
|
|
namespace Debugging {
|
|
|
|
class Debugger;
|
|
|
|
} // namespace Debugging
|
2014-01-22 16:46:20 +00:00
|
|
|
namespace Profiling {
|
|
|
|
class Profiler;
|
|
|
|
} // namespace Profiling
|
2013-08-15 12:11:19 +00:00
|
|
|
namespace CompiledData {
|
|
|
|
struct CompilationUnit;
|
|
|
|
}
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-11-11 10:22:24 +00:00
|
|
|
#define CHECK_STACK_LIMITS(v4) \
|
|
|
|
if ((v4->jsStackTop <= v4->jsStackLimit) && (reinterpret_cast<quintptr>(&v4) >= v4->cStackLimit || v4->recheckCStackLimits())) {} \
|
|
|
|
else \
|
2014-07-28 08:07:57 +00:00
|
|
|
return v4->throwRangeError(QStringLiteral("Maximum call stack size exceeded."))
|
2013-11-11 10:22:24 +00:00
|
|
|
|
|
|
|
|
2013-04-16 15:03:00 +00:00
|
|
|
struct Q_QML_EXPORT ExecutionEngine
|
2012-11-17 20:54:26 +00:00
|
|
|
{
|
2013-11-21 15:41:32 +00:00
|
|
|
private:
|
|
|
|
friend struct ExecutionContextSaver;
|
|
|
|
friend struct ExecutionContext;
|
2014-11-01 22:24:13 +00:00
|
|
|
friend struct Heap::ExecutionContext;
|
2013-11-21 15:41:32 +00:00
|
|
|
public:
|
2014-11-28 08:31:10 +00:00
|
|
|
Heap::ExecutionContext *current;
|
|
|
|
Heap::ExecutionContext *currentContext() const { return current; }
|
2013-11-21 15:41:32 +00:00
|
|
|
|
2014-02-05 15:12:16 +00:00
|
|
|
Value *jsStackTop;
|
|
|
|
quint32 hasException;
|
2014-11-28 09:05:24 +00:00
|
|
|
Heap::GlobalContext *m_rootContext;
|
|
|
|
Heap::GlobalContext *rootContext() const { return m_rootContext; }
|
2013-03-14 13:03:04 +00:00
|
|
|
|
2014-02-05 15:12:16 +00:00
|
|
|
MemoryManager *memoryManager;
|
|
|
|
ExecutableAllocator *executableAllocator;
|
|
|
|
ExecutableAllocator *regExpAllocator;
|
2014-02-14 12:58:40 +00:00
|
|
|
QScopedPointer<EvalISelFactory> iselFactory;
|
2014-02-05 15:12:16 +00:00
|
|
|
|
|
|
|
|
2014-01-24 21:55:39 +00:00
|
|
|
Value *jsStackLimit;
|
2013-11-11 10:22:24 +00:00
|
|
|
quintptr cStackLimit;
|
|
|
|
|
2013-04-19 09:47:50 +00:00
|
|
|
WTF::BumpPointerAllocator *bumperPointerAllocator; // Used by Yarr Regex engine.
|
2012-11-18 22:33:06 +00:00
|
|
|
|
2013-11-11 10:22:24 +00:00
|
|
|
enum { JSStackLimit = 4*1024*1024 };
|
2013-09-03 10:40:07 +00:00
|
|
|
WTF::PageAllocation *jsStack;
|
2014-01-24 21:55:39 +00:00
|
|
|
Value *jsStackBase;
|
2013-09-03 10:40:07 +00:00
|
|
|
|
2014-11-01 22:04:20 +00:00
|
|
|
void pushForGC(Heap::Base *m) {
|
2014-11-12 15:07:56 +00:00
|
|
|
*jsStackTop = m;
|
2013-11-02 15:30:26 +00:00
|
|
|
++jsStackTop;
|
|
|
|
}
|
2014-11-01 22:04:20 +00:00
|
|
|
Heap::Base *popForGC() {
|
2013-11-02 15:30:26 +00:00
|
|
|
--jsStackTop;
|
2014-11-01 19:56:47 +00:00
|
|
|
return jsStackTop->heapObject();
|
2013-11-02 15:30:26 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 06:57:47 +00:00
|
|
|
IdentifierTable *identifierTable;
|
2013-01-30 13:56:40 +00:00
|
|
|
|
2013-07-24 08:29:04 +00:00
|
|
|
QV4::Debugging::Debugger *debugger;
|
2014-01-22 16:46:20 +00:00
|
|
|
QV4::Profiling::Profiler *profiler;
|
2012-11-29 13:41:26 +00:00
|
|
|
|
2014-11-18 20:22:44 +00:00
|
|
|
Value m_globalObject;
|
|
|
|
Object *globalObject() { return reinterpret_cast<Object *>(&m_globalObject); }
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-04-19 11:03:42 +00:00
|
|
|
Function *globalCode;
|
2013-01-28 15:46:09 +00:00
|
|
|
|
2014-12-30 14:31:09 +00:00
|
|
|
QJSEngine *jsEngine() const;
|
2014-12-30 15:38:20 +00:00
|
|
|
QQmlEngine *qmlEngine() const;
|
2013-06-04 14:00:13 +00:00
|
|
|
QV8Engine *v8Engine;
|
2013-04-17 16:17:30 +00:00
|
|
|
|
2014-01-24 21:55:39 +00:00
|
|
|
Value objectCtor;
|
|
|
|
Value stringCtor;
|
|
|
|
Value numberCtor;
|
|
|
|
Value booleanCtor;
|
|
|
|
Value arrayCtor;
|
|
|
|
Value functionCtor;
|
|
|
|
Value dateCtor;
|
|
|
|
Value regExpCtor;
|
|
|
|
Value errorCtor;
|
|
|
|
Value evalErrorCtor;
|
|
|
|
Value rangeErrorCtor;
|
|
|
|
Value referenceErrorCtor;
|
|
|
|
Value syntaxErrorCtor;
|
|
|
|
Value typeErrorCtor;
|
|
|
|
Value uRIErrorCtor;
|
2014-09-10 12:50:28 +00:00
|
|
|
Value arrayBufferCtor;
|
2014-09-10 14:39:23 +00:00
|
|
|
Value dataViewCtor;
|
2014-09-11 13:37:31 +00:00
|
|
|
enum { NTypedArrayTypes = 9 }; // avoid header dependency
|
|
|
|
Value typedArrayCtors[NTypedArrayTypes];
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2014-11-24 14:38:41 +00:00
|
|
|
Value objectPrototype;
|
|
|
|
Value arrayPrototype;
|
|
|
|
Value stringPrototype;
|
|
|
|
Value numberPrototype;
|
|
|
|
Value booleanPrototype;
|
|
|
|
Value datePrototype;
|
|
|
|
Value functionPrototype;
|
|
|
|
Value regExpPrototype;
|
|
|
|
Value errorPrototype;
|
|
|
|
Value evalErrorPrototype;
|
|
|
|
Value rangeErrorPrototype;
|
|
|
|
Value referenceErrorPrototype;
|
|
|
|
Value syntaxErrorPrototype;
|
|
|
|
Value typeErrorPrototype;
|
|
|
|
Value uRIErrorPrototype;
|
|
|
|
Value variantPrototype;
|
|
|
|
Value sequencePrototype;
|
|
|
|
|
|
|
|
Value arrayBufferPrototype;
|
|
|
|
Value dataViewPrototype;
|
|
|
|
Value typedArrayPrototype[NTypedArrayTypes]; // TypedArray::NValues, avoid including the header here
|
|
|
|
|
2014-04-16 07:36:38 +00:00
|
|
|
InternalClassPool *classPool;
|
2013-03-04 10:48:49 +00:00
|
|
|
InternalClass *emptyClass;
|
2013-11-21 13:26:08 +00:00
|
|
|
|
2013-03-04 10:48:49 +00:00
|
|
|
InternalClass *arrayClass;
|
2013-09-01 19:22:57 +00:00
|
|
|
|
2013-08-29 19:23:04 +00:00
|
|
|
InternalClass *functionClass;
|
2013-09-01 19:22:57 +00:00
|
|
|
InternalClass *protoClass;
|
|
|
|
|
2013-09-02 12:25:15 +00:00
|
|
|
InternalClass *regExpExecArrayClass;
|
2015-01-10 19:35:18 +00:00
|
|
|
|
2013-08-16 06:53:47 +00:00
|
|
|
InternalClass *argumentsObjectClass;
|
|
|
|
InternalClass *strictArgumentsObjectClass;
|
2013-03-04 10:48:49 +00:00
|
|
|
|
2014-11-28 13:02:06 +00:00
|
|
|
Heap::EvalFunction *evalFunction;
|
2014-12-02 11:23:20 +00:00
|
|
|
Heap::FunctionObject *thrower;
|
2013-01-23 09:07:18 +00:00
|
|
|
|
2014-03-10 14:18:54 +00:00
|
|
|
Property *argumentsAccessors;
|
|
|
|
int nArgumentsAccessors;
|
2013-01-18 11:47:43 +00:00
|
|
|
|
2014-03-17 11:45:41 +00:00
|
|
|
StringValue id_empty;
|
2014-01-24 21:55:39 +00:00
|
|
|
StringValue id_undefined;
|
|
|
|
StringValue id_null;
|
|
|
|
StringValue id_true;
|
|
|
|
StringValue id_false;
|
|
|
|
StringValue id_boolean;
|
|
|
|
StringValue id_number;
|
|
|
|
StringValue id_string;
|
|
|
|
StringValue id_object;
|
|
|
|
StringValue id_function;
|
|
|
|
StringValue id_length;
|
|
|
|
StringValue id_prototype;
|
|
|
|
StringValue id_constructor;
|
|
|
|
StringValue id_arguments;
|
|
|
|
StringValue id_caller;
|
|
|
|
StringValue id_callee;
|
|
|
|
StringValue id_this;
|
|
|
|
StringValue id___proto__;
|
|
|
|
StringValue id_enumerable;
|
|
|
|
StringValue id_configurable;
|
|
|
|
StringValue id_writable;
|
|
|
|
StringValue id_value;
|
|
|
|
StringValue id_get;
|
|
|
|
StringValue id_set;
|
|
|
|
StringValue id_eval;
|
|
|
|
StringValue id_uintMax;
|
|
|
|
StringValue id_name;
|
|
|
|
StringValue id_index;
|
|
|
|
StringValue id_input;
|
|
|
|
StringValue id_toString;
|
2014-02-27 21:59:39 +00:00
|
|
|
StringValue id_destroy;
|
2014-01-24 21:55:39 +00:00
|
|
|
StringValue id_valueOf;
|
2014-09-10 12:50:28 +00:00
|
|
|
StringValue id_byteLength;
|
2014-09-10 14:39:23 +00:00
|
|
|
StringValue id_byteOffset;
|
|
|
|
StringValue id_buffer;
|
2014-11-11 14:08:30 +00:00
|
|
|
StringValue id_lastIndex;
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-08-15 12:11:19 +00:00
|
|
|
QSet<CompiledData::CompilationUnit*> compilationUnits;
|
2012-11-28 12:39:14 +00:00
|
|
|
|
2013-06-04 08:05:51 +00:00
|
|
|
quint32 m_engineId;
|
|
|
|
|
2013-03-30 16:43:03 +00:00
|
|
|
RegExpCache *regExpCache;
|
|
|
|
|
2013-05-14 00:01:04 +00:00
|
|
|
// Scarce resources are "exceptionally high cost" QVariant types where allowing the
|
|
|
|
// normal JavaScript GC to clean them up is likely to lead to out-of-memory or other
|
|
|
|
// out-of-resource situations. When such a resource is passed into JavaScript we
|
|
|
|
// add it to the scarceResources list and it is destroyed when we return from the
|
|
|
|
// JavaScript execution that created it. The user can prevent this behavior by
|
|
|
|
// calling preserve() on the object which removes it from this scarceResource list.
|
|
|
|
class ScarceResourceData {
|
|
|
|
public:
|
2014-04-29 14:46:12 +00:00
|
|
|
ScarceResourceData(const QVariant &data = QVariant()) : data(data) {}
|
2013-05-14 00:01:04 +00:00
|
|
|
QVariant data;
|
|
|
|
QIntrusiveListNode node;
|
|
|
|
};
|
|
|
|
QIntrusiveList<ScarceResourceData, &ScarceResourceData::node> scarceResources;
|
|
|
|
|
2013-06-04 12:28:13 +00:00
|
|
|
// Normally the JS wrappers for QObjects are stored in the QQmlData/QObjectPrivate,
|
|
|
|
// but any time a QObject is wrapped a second time in another engine, we have to do
|
|
|
|
// bookkeeping.
|
|
|
|
MultiplyWrappedQObjectMap *m_multiplyWrappedQObjects;
|
|
|
|
|
2014-02-14 12:58:40 +00:00
|
|
|
ExecutionEngine(EvalISelFactory *iselFactory = 0);
|
2012-12-04 10:30:26 +00:00
|
|
|
~ExecutionEngine();
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-07-24 08:29:04 +00:00
|
|
|
void enableDebugger();
|
2014-01-22 16:46:20 +00:00
|
|
|
void enableProfiler();
|
2013-07-24 08:29:04 +00:00
|
|
|
|
2014-11-28 09:05:24 +00:00
|
|
|
Heap::ExecutionContext *pushGlobalContext();
|
2013-11-03 14:23:05 +00:00
|
|
|
void pushContext(CallContext *context);
|
2014-11-28 08:31:10 +00:00
|
|
|
Heap::ExecutionContext *popContext();
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::Object *newObject();
|
2014-11-24 14:38:41 +00:00
|
|
|
Heap::Object *newObject(InternalClass *internalClass, Object *prototype);
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2014-11-28 08:20:29 +00:00
|
|
|
Heap::String *newString(const QString &s = QString());
|
2014-11-11 14:08:30 +00:00
|
|
|
Heap::String *newIdentifier(const QString &text);
|
2013-01-30 13:56:40 +00:00
|
|
|
|
2015-01-15 10:36:57 +00:00
|
|
|
Heap::Object *newStringObject(const Value &value);
|
2015-01-16 11:44:51 +00:00
|
|
|
Heap::Object *newNumberObject(double value);
|
2015-01-15 20:54:12 +00:00
|
|
|
Heap::Object *newBooleanObject(bool b);
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::ArrayObject *newArrayObject(int count = 0);
|
|
|
|
Heap::ArrayObject *newArrayObject(const QStringList &list);
|
2014-11-24 14:38:41 +00:00
|
|
|
Heap::ArrayObject *newArrayObject(InternalClass *ic, Object *prototype);
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2015-01-15 10:36:57 +00:00
|
|
|
Heap::DateObject *newDateObject(const Value &value);
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::DateObject *newDateObject(const QDateTime &dt);
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::RegExpObject *newRegExpObject(const QString &pattern, int flags);
|
|
|
|
Heap::RegExpObject *newRegExpObject(RegExp *re, bool global);
|
|
|
|
Heap::RegExpObject *newRegExpObject(const QRegExp &re);
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2015-01-15 10:36:57 +00:00
|
|
|
Heap::Object *newErrorObject(const Value &value);
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::Object *newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column);
|
|
|
|
Heap::Object *newSyntaxErrorObject(const QString &message);
|
|
|
|
Heap::Object *newReferenceErrorObject(const QString &message);
|
|
|
|
Heap::Object *newReferenceErrorObject(const QString &message, const QString &fileName, int lineNumber, int columnNumber);
|
|
|
|
Heap::Object *newTypeErrorObject(const QString &message);
|
|
|
|
Heap::Object *newRangeErrorObject(const QString &message);
|
2015-01-15 10:36:57 +00:00
|
|
|
Heap::Object *newURIErrorObject(const Value &message);
|
2012-12-04 18:50:25 +00:00
|
|
|
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::Object *newVariantObject(const QVariant &v);
|
2013-05-14 00:01:04 +00:00
|
|
|
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::Object *newForEachIteratorObject(Object *o);
|
2013-01-18 11:47:43 +00:00
|
|
|
|
2014-11-11 12:34:18 +00:00
|
|
|
Heap::Object *qmlContextObject() const;
|
2013-05-03 14:51:32 +00:00
|
|
|
|
2013-05-25 13:31:23 +00:00
|
|
|
StackTrace stackTrace(int frameLimit = -1) const;
|
2013-05-22 08:47:36 +00:00
|
|
|
StackFrame currentStackFrame() const;
|
2013-05-29 07:59:40 +00:00
|
|
|
QUrl resolvedUrl(const QString &file);
|
2013-05-22 08:47:36 +00:00
|
|
|
|
2013-01-18 11:47:43 +00:00
|
|
|
void requireArgumentsAccessors(int n);
|
2013-01-28 15:46:09 +00:00
|
|
|
|
|
|
|
void markObjects();
|
2013-03-05 15:11:22 +00:00
|
|
|
|
2013-03-14 13:03:04 +00:00
|
|
|
void initRootContext();
|
2013-05-06 11:29:24 +00:00
|
|
|
|
|
|
|
InternalClass *newClass(const InternalClass &other);
|
2013-05-25 13:31:23 +00:00
|
|
|
|
2013-06-20 09:32:45 +00:00
|
|
|
QmlExtensions *qmlExtensions();
|
|
|
|
|
2013-11-11 10:22:24 +00:00
|
|
|
bool recheckCStackLimits();
|
|
|
|
|
2013-10-01 14:19:28 +00:00
|
|
|
// Exception handling
|
2014-01-24 21:55:39 +00:00
|
|
|
Value exceptionValue;
|
2013-10-01 14:19:28 +00:00
|
|
|
StackTrace exceptionStackTrace;
|
|
|
|
|
2015-01-15 10:36:57 +00:00
|
|
|
ReturnedValue throwError(const Value &value);
|
2014-11-12 12:55:55 +00:00
|
|
|
ReturnedValue catchException(StackTrace *trace = 0);
|
2013-10-01 14:19:28 +00:00
|
|
|
|
2014-07-28 08:07:57 +00:00
|
|
|
ReturnedValue throwError(const QString &message);
|
|
|
|
ReturnedValue throwSyntaxError(const QString &message);
|
|
|
|
ReturnedValue throwSyntaxError(const QString &message, const QString &fileName, int lineNumber, int column);
|
|
|
|
ReturnedValue throwTypeError();
|
|
|
|
ReturnedValue throwTypeError(const QString &message);
|
2015-01-15 10:36:57 +00:00
|
|
|
ReturnedValue throwReferenceError(const Value &value);
|
2014-07-28 08:07:57 +00:00
|
|
|
ReturnedValue throwReferenceError(const QString &value, const QString &fileName, int lineNumber, int column);
|
2015-01-15 10:36:57 +00:00
|
|
|
ReturnedValue throwRangeError(const Value &value);
|
2014-07-28 08:07:57 +00:00
|
|
|
ReturnedValue throwRangeError(const QString &message);
|
2015-01-15 10:36:57 +00:00
|
|
|
ReturnedValue throwURIError(const Value &msg);
|
2014-07-28 08:07:57 +00:00
|
|
|
ReturnedValue throwUnimplemented(const QString &message);
|
|
|
|
|
2013-10-17 06:56:51 +00:00
|
|
|
// Use only inside catch(...) -- will re-throw if no JS exception
|
2014-11-12 12:55:55 +00:00
|
|
|
QQmlError catchExceptionAsQmlError();
|
2013-10-17 06:56:51 +00:00
|
|
|
|
2015-01-02 13:37:26 +00:00
|
|
|
// variant conversions
|
2015-01-15 10:36:57 +00:00
|
|
|
QVariant toVariant(const QV4::Value &value, int typeHint, bool createJSValueForObjects = true);
|
2015-01-02 14:07:35 +00:00
|
|
|
QV4::ReturnedValue fromVariant(const QVariant &);
|
2015-01-02 13:37:26 +00:00
|
|
|
|
2015-01-02 14:07:35 +00:00
|
|
|
QVariantMap variantMapFromJS(QV4::Object *o);
|
2015-01-02 13:37:26 +00:00
|
|
|
|
2015-01-15 10:36:57 +00:00
|
|
|
bool metaTypeFromJS(const Value &value, int type, void *data);
|
2015-01-02 14:07:35 +00:00
|
|
|
QV4::ReturnedValue metaTypeToJS(int type, const void *data);
|
2015-01-02 13:37:26 +00:00
|
|
|
|
2013-06-20 09:32:45 +00:00
|
|
|
private:
|
|
|
|
QmlExtensions *m_qmlExtensions;
|
2013-03-05 15:11:22 +00:00
|
|
|
};
|
|
|
|
|
2014-11-18 16:35:48 +00:00
|
|
|
inline void ExecutionEngine::pushContext(CallContext *context)
|
|
|
|
{
|
2014-11-28 08:31:10 +00:00
|
|
|
Q_ASSERT(current && context && context->d());
|
|
|
|
context->d()->parent = current;
|
|
|
|
current = context->d();
|
2014-11-18 16:35:48 +00:00
|
|
|
}
|
|
|
|
|
2014-11-28 08:31:10 +00:00
|
|
|
inline Heap::ExecutionContext *ExecutionEngine::popContext()
|
2014-11-18 16:35:48 +00:00
|
|
|
{
|
2014-11-28 08:31:10 +00:00
|
|
|
Q_ASSERT(current->parent);
|
|
|
|
current = current->parent;
|
|
|
|
Q_ASSERT(current);
|
2014-11-18 16:35:48 +00:00
|
|
|
return current;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
Heap::ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t)
|
2015-01-19 15:36:17 +00:00
|
|
|
: engine(engine)
|
2014-11-28 08:31:10 +00:00
|
|
|
, parent(engine->currentContext())
|
2014-11-18 16:35:48 +00:00
|
|
|
, outer(0)
|
|
|
|
, lookups(0)
|
|
|
|
, compilationUnit(0)
|
2015-01-19 15:36:17 +00:00
|
|
|
, type(t)
|
|
|
|
, strictMode(false)
|
2014-11-18 16:35:48 +00:00
|
|
|
, lineNumber(-1)
|
|
|
|
{
|
2014-11-28 08:31:10 +00:00
|
|
|
engine->current = this;
|
2014-11-18 16:35:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-01 19:56:47 +00:00
|
|
|
// ### Remove me
|
2013-11-02 15:30:26 +00:00
|
|
|
inline
|
|
|
|
void Managed::mark(QV4::ExecutionEngine *engine)
|
|
|
|
{
|
2014-04-05 18:23:20 +00:00
|
|
|
Q_ASSERT(inUse());
|
|
|
|
if (markBit())
|
2013-11-02 15:30:26 +00:00
|
|
|
return;
|
2015-01-09 21:02:40 +00:00
|
|
|
d()->setMarkBit();
|
2014-11-01 19:56:47 +00:00
|
|
|
engine->pushForGC(d());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
2014-11-01 22:04:20 +00:00
|
|
|
void Heap::Base::mark(QV4::ExecutionEngine *engine)
|
2014-11-01 19:56:47 +00:00
|
|
|
{
|
2015-01-09 18:48:56 +00:00
|
|
|
Q_ASSERT(inUse());
|
2015-01-09 21:02:40 +00:00
|
|
|
if (isMarked())
|
2014-11-01 19:56:47 +00:00
|
|
|
return;
|
2015-01-09 21:02:40 +00:00
|
|
|
setMarkBit();
|
2013-11-02 15:30:26 +00:00
|
|
|
engine->pushForGC(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-19 11:03:42 +00:00
|
|
|
} // namespace QV4
|
2012-11-17 20:54:26 +00:00
|
|
|
|
2013-01-31 09:00:06 +00:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2013-03-18 10:03:51 +00:00
|
|
|
#endif // QV4ENGINE_H
|