Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4function_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4#ifndef QV4FUNCTION_H
5#define QV4FUNCTION_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qqmlprivate.h>
19#include "qv4global_p.h"
20#include <private/qv4executablecompilationunit_p.h>
21#include <private/qv4context_p.h>
22#include <private/qv4string_p.h>
23
24namespace JSC {
25class MacroAssemblerCodeRef;
26}
27
28QT_BEGIN_NAMESPACE
29
30struct QQmlSourceLocation;
31
32namespace QV4 {
33
34struct Q_QML_EXPORT FunctionData
35{
37
38 // Intentionally require an ExecutableCompilationUnit but save only a pointer to
39 // CompilationUnitBase. This is so that we can take advantage of the standard layout
40 // of CompilationUnitBase in the JIT. Furthermore we can safely static_cast to
41 // ExecutableCompilationUnit where we need it.
43};
44// Make sure this class can be accessed through offsetof (done by the assemblers):
46
47struct Q_QML_EXPORT Function : public FunctionData {
48protected:
51 ~Function();
52
53public:
57
61
63 {
64 // This is safe: We require an ExecutableCompilationUnit in the ctor.
65 return static_cast<QV4::ExecutableCompilationUnit *>(compilationUnit.get());
66 }
67
69 {
71 }
72
73 bool call(QObject *thisObject, void **a, const QMetaType *types, int argc,
75 ReturnedValue call(const Value *thisObject, const Value *argv, int argc,
77
79 const char *codeData = nullptr;
81
83 typedef void (*AotCompiledCode)(const QQmlPrivate::AOTCompiledContext *context, void **argv);
84
85 union {
86 void *noFunction = nullptr;
89 };
90
91 union {
94 };
95
96 // first nArguments names in internalClass are the actual arguments
103
107 void destroy();
108
109 void mark(QV4::MarkStack *ms);
110
111 // used when dynamically assigning signal handlers (QQmlConnection)
113
114 inline Heap::String *name() const {
116 }
117
118 static QString prettyName(const Function *function, const void *address);
119
120 inline QString sourceFile() const { return executableCompilationUnit()->fileName(); }
121 inline QUrl finalUrl() const { return executableCompilationUnit()->finalUrl(); }
122
123 inline bool isStrict() const { return compiledFunction->flags & CompiledData::Function::IsStrict; }
127
129
136
137 bool isJittable() const { return kind != Function::AotCompiled && !isGenerator(); }
138};
139
140}
141
142QT_END_NAMESPACE
143
144#endif
DECLARE_HEAP_OBJECT(DynamicFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(BoundFunction, JavaScriptFunctionObject)
DECLARE_HEAP_OBJECT(ConstructorFunction, ScriptFunction)
DECLARE_HEAP_OBJECT(FunctionObject, Object)
DECLARE_HEAP_OBJECT(JavaScriptFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(MemberFunction, ArrowFunction)
DECLARE_HEAP_OBJECT(ScriptFunction, ArrowFunction)
Definition qjsvalue.h:23
ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
DEFINE_OBJECT_VTABLE(SharedArrayBufferCtor)
DEFINE_OBJECT_VTABLE(ArrayBufferCtor)
DEFINE_OBJECT_VTABLE(ArrayBuffer)
DEFINE_OBJECT_VTABLE(SharedArrayBuffer)
#define V4_NEEDS_DESTROY
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
#define RETURN_UNDEFINED()
static ReturnedValue method_isView(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static void virtualCallWithMetaTypes(const FunctionObject *f, QObject *thisObject, void **a, const QMetaType *types, int argc)
static ReturnedValue virtualCall(const QV4::FunctionObject *f, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static QQmlRefPointer< ExecutableCompilationUnit > parse(ExecutionEngine *engine, const Value *argv, int argc, Type t=Type_Function)
static ReturnedValue method_bind(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_hasInstance(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(QV4::ExecutionEngine *engine)
void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name=nullptr)
void init(QV4::ExecutionEngine *engine)
void init(QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call)
void init(QV4::ExecutionEngine *engine)
Heap::InternalClass * classForConstructor() const
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool shared)