class QQmlProfiler : public QObject, public QQmlProfilerDefinitions {
Q_OBJECT
public:
- void startBinding(const QString &fileName, int line, int column)
+ void startBinding(const QQmlSourceLocation &location)
{
m_data.append(QQmlProfilerData(m_timer.nsecsElapsed(),
(1 << RangeStart | 1 << RangeLocation), 1 << Binding,
- fileName, line, column));
+ location.sourceFile, qmlSourceCoordinate(location.line), qmlSourceCoordinate(location.column)));
}
// Have toByteArrays() construct another RangeData event from the same QString later.
};
struct QQmlBindingProfiler : public QQmlProfilerHelper {
- QQmlBindingProfiler(QQmlProfiler *profiler, const QString &url, int line, int column) :
+ QQmlBindingProfiler(QQmlProfiler *profiler, const QV4::FunctionObject *function) :
QQmlProfilerHelper(profiler)
{
Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileBinding, profiler,
- startBinding(url, line, column));
+ startBinding(function->sourceLocation()));
}
~QQmlBindingProfiler()
return d()->vtable == BoundFunction::staticVTable();
}
+QQmlSourceLocation FunctionObject::sourceLocation() const
+{
+ if (isBinding()) {
+ Q_ASSERT(as<const QV4::QQmlBindingFunction>());
+ return static_cast<QV4::Heap::QQmlBindingFunction *>(d())->bindingLocation;
+ }
+ QV4::Function *function = d()->function;
+ Q_ASSERT(function);
+
+ return QQmlSourceLocation(function->sourceFile(), function->compiledFunction->location.line, function->compiledFunction->location.column);
+}
+
DEFINE_OBJECT_VTABLE(FunctionCtor);
Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope)
QT_BEGIN_NAMESPACE
+struct QQmlSourceLocation;
+
namespace QV4 {
namespace Heap {
bool isBinding() const;
bool isBoundFunction() const;
+ QQmlSourceLocation sourceLocation() const;
+
static void markObjects(Heap::Base *that, ExecutionEngine *e);
};
if (QQmlData::wasDeleted(object()))
return;
- QString url;
- quint16 lineNumber;
- quint16 columnNumber;
-
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine);
QV4::Scope scope(ep->v4engine());
QV4::ScopedFunctionObject f(scope, v4function.value());
Q_ASSERT(f);
- if (f->isBinding()) {
- Q_ASSERT(f->as<QV4::QQmlBindingFunction>());
- QQmlSourceLocation loc = static_cast<QV4::Heap::QQmlBindingFunction *>(f->d())->bindingLocation;
- url = loc.sourceFile;
- lineNumber = loc.line;
- columnNumber = loc.column;
- } else {
- QV4::Function *function = f->asFunctionObject()->function();
- Q_ASSERT(function);
-
- url = function->sourceFile();
- lineNumber = function->compiledFunction->location.line;
- columnNumber = function->compiledFunction->location.column;
- }
-
- int lineNo = qmlSourceCoordinate(lineNumber);
- int columnNo = qmlSourceCoordinate(columnNumber);
if (!updatingFlag()) {
- QQmlBindingProfiler prof(ep->profiler, url, lineNo, columnNo);
+ QQmlBindingProfiler prof(ep->profiler, f);
setUpdatingFlag(true);
QQmlAbstractExpression::DeleteWatcher watcher(this);
if (!watcher.wasDeleted()) {
if (needsErrorLocationData)
- delayedError()->setErrorLocation(QUrl(url), lineNumber, columnNumber);
+ delayedError()->setErrorLocation(f->sourceLocation());
if (hasError()) {
if (!delayedError()->addError(ep)) ep->warning(this->error(context()->engine));
#include <private/qv4script_p.h>
#include <private/qv4errorobject_p.h>
#include <private/qv4scopedvalue_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_NAMESPACE
return true;
}
-void QQmlDelayedError::setErrorLocation(const QUrl &url, quint16 line, quint16 column)
+void QQmlDelayedError::setErrorLocation(const QQmlSourceLocation &sourceLocation)
{
- m_error.setUrl(url);
- m_error.setLine(line);
- m_error.setColumn(column);
+ m_error.setUrl(QUrl(sourceLocation.sourceFile));
+ m_error.setLine(sourceLocation.line);
+ m_error.setColumn(sourceLocation.column);
}
void QQmlDelayedError::setErrorDescription(const QString &description)
QT_BEGIN_NAMESPACE
+class QQmlSourceLocation;
+
class QQmlDelayedError
{
public:
inline const QQmlError &error() const { return m_error; }
inline void clearError() { m_error = QQmlError(); }
- void setErrorLocation(const QUrl &url, quint16 line, quint16 column);
+ void setErrorLocation(const QQmlSourceLocation &sourceLocation);
void setErrorDescription(const QString &description);
void setErrorObject(QObject *object);