summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/script/qmlbasicscript.h
blob: 5ef214827bac0a90b31feb3dd694f1e6aa655925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
****************************************************************************/

#ifndef QMLBASICSCRIPT_H
#define QMLBASICSCRIPT_H

#include "instructions.h"
#include <QtCore/QList>
#include <QtCore/QByteArray>
#include "lexer.h"
#include <QtCore/QVariant>


QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Declarative)
class QmlRefCount;
class QmlContext;
class QmlBasicScriptPrivate;
class QmlBasicScriptNodeCache;
class QmlBasicScript
{
public:
    QmlBasicScript();
    QmlBasicScript(const char *, QmlRefCount * = 0);
    ~QmlBasicScript();

    // Always 4-byte aligned
    const char *compileData() const;
    unsigned int compileDataSize() const;

    QByteArray expression() const;

    bool compile(const QByteArray &);
    bool compile(const char *);
    bool isValid() const;

    void clear();

    void dump();
    void *newScriptState();
    void deleteScriptState(void *);

    enum CacheState { NoChange, Incremental, Reset };
    QVariant run(QmlContext *, void *, CacheState *);

    // Optimization opportunities
    bool isSingleLoad() const;
    QByteArray singleLoadTarget() const;

private:
    int flags;
    QmlBasicScriptPrivate *d;
    QmlRefCount *rc;

    void clearCache(void *);
    void guard(QmlBasicScriptNodeCache &);
    bool valid(QmlBasicScriptNodeCache &, QObject *);
};

#endif // QMLBASICSCRIPT_H


QT_END_NAMESPACE

QT_END_HEADER