for (int i = 0; i < data->stringTableSize; ++i)
runtimeStrings[i] = engine->newIdentifier(data->stringAt(i)->qString());
- runtimeFunctions.resize(data->functionTableSize);
- for (int i = 0; i < data->functionTableSize; ++i)
- runtimeFunctions[i] = new QV4::Function(engine, runtimeStrings[data->functionAt(i)->nameIndex]);
-
runtimeRegularExpressions = new QV4::Value[data->regexpTableSize];
for (int i = 0; i < data->regexpTableSize; ++i) {
const CompiledData::RegExp *re = data->regexpAt(i);
const CompiledData::Function *compiledRootFunction = data->functionAt(data->indexOfRootFunction);
+ runtimeFunctions.resize(data->functionTableSize);
+
for (int i = 0 ;i < runtimeFunctions.size(); ++i) {
- QV4::Function *runtimeFunction = runtimeFunctions.at(i);
const CompiledData::Function *compiledFunction = data->functionAt(i);
- runtimeFunction->init(this, compiledFunction,
- (Value (*)(QV4::ExecutionContext *, const uchar *)) codeRefs[i].code().executableAddress(),
- codeRefs[i].size());
+ QV4::Function *runtimeFunction = new QV4::Function(engine, this, compiledFunction,
+ (Value (*)(QV4::ExecutionContext *, const uchar *)) codeRefs[i].code().executableAddress(),
+ codeRefs[i].size());
+ runtimeFunctions[i] = runtimeFunction;
if (compiledFunction == compiledRootFunction) {
assert(!rootRuntimeFunction);
const QV4::CompiledData::Function *compiledRootFunction = data->functionAt(data->indexOfRootFunction);
+ runtimeFunctions.resize(data->functionTableSize);
+
for (int i = 0 ;i < runtimeFunctions.size(); ++i) {
- QV4::Function *runtimeFunction = runtimeFunctions.at(i);
const QV4::CompiledData::Function *compiledFunction = data->functionAt(i);
- runtimeFunction->init(this, compiledFunction,
- &VME::exec, /*size - doesn't matter for moth*/0);
-
+ QV4::Function *runtimeFunction = new QV4::Function(engine, this, compiledFunction,
+ &VME::exec, /*size - doesn't matter for moth*/0);
runtimeFunction->codeData = reinterpret_cast<const uchar *>(codeRefs.at(i).constData());
+ runtimeFunctions[i] = runtimeFunction;
if (QV4::Debugging::Debugger *debugger = engine->debugger)
debugger->setPendingBreakpoints(runtimeFunction);
using namespace QV4;
-Function::~Function()
-{
-}
-
-void Function::init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function, Value (*codePtr)(ExecutionContext *, const uchar *),
- quint32 _codeSize)
+Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
+ Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize)
+ : name(0)
+ , compiledFunction(0)
+ , compilationUnit(0)
+ , code(0)
+ , codeData(0)
+ , codeSize(0)
+ , engine(engine)
{
Q_ASSERT(!compilationUnit);
compilationUnit = unit;
compiledFunction = function;
+ name = compilationUnit->runtimeStrings[compiledFunction->nameIndex];
+
code = codePtr;
codeSize = _codeSize;
locals[i] = engine->newString(unit->data->stringAt(localsIndices[i])->qString());
}
+Function::~Function()
+{
+}
+
+
void Function::mark()
{
if (name)
ExecutionEngine *engine;
- Function(ExecutionEngine *engine, String *name)
- : name(name)
- , compiledFunction(0)
- , compilationUnit(0)
- , code(0)
- , codeData(0)
- , codeSize(0)
- , engine(engine)
- {}
+ Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
+ Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize);
~Function();
- // ### Merge with constructor later.
- void init(CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
- Value (*codePtr)(ExecutionContext *, const uchar *), quint32 _codeSize);
-
inline QString sourceFile() const { return compilationUnit->fileName(); }
inline bool usesArgumentsObject() const { return compiledFunction->flags & CompiledData::Function::UsesArgumentsObject; }