Add a sourceLocation() accessor to QV4::Function

Change-Id: I3a38ee44ce46c2416ceef153ce631bc15fd461fe
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Lars Knoll 2016-11-29 15:23:34 +01:00
parent e31e72925f
commit 83aa1933c8
2 changed files with 7 additions and 3 deletions

View File

@ -51,6 +51,7 @@
//
#include "qv4global_p.h"
#include <private/qqmlglobal_p.h>
#include <private/qv4compileddata_p.h>
QT_BEGIN_NAMESPACE
@ -89,6 +90,11 @@ struct Q_QML_EXPORT Function {
inline bool needsActivation() const
{ return activationRequired; }
QQmlSourceLocation sourceLocation() const
{
return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column);
}
};
}

View File

@ -237,10 +237,8 @@ QQmlSourceLocation FunctionObject::sourceLocation() const
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);
return d()->function->sourceLocation();
}
DEFINE_OBJECT_VTABLE(FunctionCtor);