Qt 4.8
Classes | Public Functions | Static Public Functions | Properties | List of all members
QDeclarativeBindingCompiler Class Reference

#include <qdeclarativecompiledbindings_p.h>

Classes

struct  Expression
 

Public Functions

int compile (const Expression &, QDeclarativeEnginePrivate *)
 
bool isValid () const
 
QByteArray program () const
 
 QDeclarativeBindingCompiler ()
 
 ~QDeclarativeBindingCompiler ()
 

Static Public Functions

static void dump (const QByteArray &)
 

Properties

QDeclarativeBindingCompilerPrivated
 

Detailed Description

Definition at line 64 of file qdeclarativecompiledbindings_p.h.

Constructors and Destructors

◆ QDeclarativeBindingCompiler()

QDeclarativeBindingCompiler::QDeclarativeBindingCompiler ( )

◆ ~QDeclarativeBindingCompiler()

QDeclarativeBindingCompiler::~QDeclarativeBindingCompiler ( )

Definition at line 2842 of file qdeclarativecompiledbindings.cpp.

2843 {
2844  delete d; d = 0;
2845 }
QDeclarativeBindingCompilerPrivate * d

Functions

◆ compile()

int QDeclarativeBindingCompiler::compile ( const Expression expression,
QDeclarativeEnginePrivate engine 
)

Definition at line 2858 of file qdeclarativecompiledbindings.cpp.

Referenced by QDeclarativeCompiler::completeComponentBuild().

2859 {
2860  if (!expression.expression.asAST()) return false;
2861 
2862  if (!qmlExperimental() && expression.property->isValueTypeSubProperty)
2863  return -1;
2864 
2865  if (qmlDisableOptimizer())
2866  return -1;
2867 
2868  d->context = expression.context;
2869  d->component = expression.component;
2870  d->destination = expression.property;
2871  d->ids = expression.ids;
2872  d->imports = expression.imports;
2873  d->engine = engine;
2874 
2875  if (d->compile(expression.expression.asAST())) {
2876  return d->commitCompile();
2877  } else {
2878  return -1;
2879  }
2880 }
int commitCompile()
Mark the last compile as successful, and add it to the "committed data" section.
QDeclarativeBindingCompilerPrivate * d
QHash< QString, QDeclarativeParser::Object * > ids

◆ dump()

void QDeclarativeBindingCompiler::dump ( const QByteArray programData)
static

Definition at line 1695 of file qdeclarativecompiledbindings.cpp.

Referenced by QDeclarativeCompiler::completeComponentBuild().

1696 {
1697  const Program *program = (const Program *)programData.constData();
1698 
1699  qWarning() << "Program.bindings:" << program->bindings;
1700  qWarning() << "Program.dataLength:" << program->dataLength;
1701  qWarning() << "Program.subscriptions:" << program->subscriptions;
1702  qWarning() << "Program.indentifiers:" << program->identifiers;
1703 
1704  int count = program->instructionCount;
1705  const Instr *instr = program->instructions();
1706 
1707  while (count--) {
1708 
1709  dumpInstruction(instr);
1710  ++instr;
1711  }
1712 }
Q_CORE_EXPORT void qWarning(const char *,...)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static void dumpInstruction(const Instr *instr)

◆ isValid()

bool QDeclarativeBindingCompiler::isValid ( ) const

Definition at line 2850 of file qdeclarativecompiledbindings.cpp.

Referenced by QDeclarativeCompiler::completeComponentBuild(), and program().

2851 {
2852  return !d->committed.bytecode.isEmpty();
2853 }
struct QDeclarativeBindingCompilerPrivate::@134 committed
QDeclarativeBindingCompilerPrivate * d
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139

◆ program()

QByteArray QDeclarativeBindingCompiler::program ( ) const

Definition at line 2918 of file qdeclarativecompiledbindings.cpp.

Referenced by QDeclarativeCompiler::completeComponentBuild().

2919 {
2920  QByteArray programData;
2921 
2922  if (isValid()) {
2923  Program prog;
2924  prog.bindings = d->committed.count();
2925 
2926  QVector<Instr> bytecode;
2927  Instr skip;
2928  skip.common.type = Instr::Skip;
2929  skip.skip.reg = -1;
2930  for (int ii = 0; ii < d->committed.count(); ++ii) {
2931  skip.skip.count = d->committed.count() - ii - 1;
2932  skip.skip.count+= d->committed.offsets.at(ii);
2933  bytecode << skip;
2934  }
2935  bytecode << d->committed.bytecode;
2936 
2938  while (data.count() % 4) data.append('\0');
2939  prog.signalTableOffset = data.count();
2940  data += d->buildSignalTable();
2941  while (data.count() % 4) data.append('\0');
2942  prog.exceptionDataOffset = data.count();
2943  data += d->buildExceptionData();
2944 
2945  prog.dataLength = 4 * ((data.size() + 3) / 4);
2946  prog.subscriptions = d->committed.subscriptionIds.count();
2947  prog.identifiers = d->committed.registeredStrings.count();
2948  prog.instructionCount = bytecode.count();
2949  prog.compiled = false;
2950  int size = sizeof(Program) + bytecode.count() * sizeof(Instr);
2951  size += prog.dataLength;
2952 
2953  programData.resize(size);
2954  memcpy(programData.data(), &prog, sizeof(Program));
2955  if (prog.dataLength)
2956  memcpy((char *)((Program *)programData.data())->data(), data.constData(),
2957  data.size());
2958  memcpy((char *)((Program *)programData.data())->instructions(), bytecode.constData(),
2959  bytecode.count() * sizeof(Instr));
2960  }
2961 
2962  return programData;
2963 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
QByteArray & append(char c)
Appends the character ch to this byte array.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
struct QDeclarativeBindingCompilerPrivate::@134 committed
QHash< QString, QPair< int, int > > registeredStrings
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static const char * data(const QByteArray &arr)
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int count(char c) const
Returns the number of occurrences of character ch in the byte array.
void resize(int size)
Sets the size of the byte array to size bytes.
QDeclarativeBindingCompilerPrivate * d
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
int count(const Key &key) const
Returns the number of items associated with the key.
Definition: qhash.h:719
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154

Properties

◆ d

QDeclarativeBindingCompilerPrivate* QDeclarativeBindingCompiler::d
private

The documentation for this class was generated from the following files: