aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4function_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime/qv4function_p.h')
-rw-r--r--src/qml/jsruntime/qv4function_p.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 3ff31ed2e3..612bbb122e 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -87,6 +87,7 @@ struct LineNumberMapping
};
struct Function {
+ int refCount;
String *name;
Value (*code)(ExecutionContext *, const uchar *);
@@ -111,8 +112,11 @@ struct Function {
QString sourceFile;
QVector<LineNumberMapping> lineNumberMappings;
- Function(String *name)
- : name(name)
+ ExecutionEngine *engine;
+
+ Function(ExecutionEngine *engine, String *name)
+ : refCount(0)
+ , name(name)
, code(0)
, codeData(0)
, codeSize(0)
@@ -122,9 +126,19 @@ struct Function {
, usesArgumentsObject(false)
, isStrict(false)
, isNamedExpression(false)
+ , engine(engine)
{}
~Function();
+ void ref() { ++refCount; }
+ void deref() { if (!--refCount) delete this; }
+
+ void addNestedFunction(Function *f)
+ {
+ f->ref();
+ nestedFunctions.append(f);
+ }
+
inline bool needsActivation() const { return hasNestedFunctions || hasDirectEval || usesArgumentsObject; }
void mark();