f = f->outer;
}
- if (!e->parent && (!f || !f->insideWithOrCatch) && _mode != EvalCode && (!f || f->name != name))
+ if (!e->parent && (!f || !f->insideWithOrCatch) && _mode != EvalCode && _mode != QmlBinding && (!f || f->name != name))
return _block->GLOBALNAME(name, line, col);
// global context or with. Lookup by name
}
if (args) {
V4IR::ExprList *next = function->New<V4IR::ExprList>();
- next->expr = entryBlock->CONST(V4IR::BoolType, mode == EvalCode);
+ next->expr = entryBlock->CONST(V4IR::BoolType, (mode == EvalCode || mode == QmlBinding));
next->next = args;
args = next;
bool Codegen::visit(ExpressionStatement *ast)
{
- if (_mode == EvalCode) {
+ if (_mode == EvalCode || _mode == QmlBinding) {
Result e = expression(ast->expression);
if (*e)
move(_block->TEMP(_returnAddress), *e);
bool Codegen::visit(ReturnStatement *ast)
{
- if (_mode != FunctionCode)
+ if (_mode != FunctionCode && _mode != QmlBinding)
throwSyntaxError(ast->returnToken, QCoreApplication::translate("qv4codegen", "Return statement outside of function"));
if (ast->expression) {
Result expr = expression(ast->expression);
enum Mode {
GlobalCode,
EvalCode,
- FunctionCode
+ FunctionCode,
+ QmlBinding
};
V4IR::Function *operator()(const QString &fileName,
inheritedLocals.append(*i ? (*i)->toQString() : QString());
Codegen cg(scope, strictMode);
- V4IR::Function *globalIRCode = cg(sourceFile, sourceCode, program, &module, QQmlJS::Codegen::EvalCode, inheritedLocals);
+ V4IR::Function *globalIRCode = cg(sourceFile, sourceCode, program, &module,
+ parseAsBinding ? QQmlJS::Codegen::QmlBinding : QQmlJS::Codegen::EvalCode, inheritedLocals);
QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(v4, &module));
if (inheritContext)
isel->setUseFastLookups(false);
Script(ExecutionContext *scope, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0)
: sourceFile(source), line(line), column(column), sourceCode(sourceCode)
, scope(scope), strictMode(false), inheritContext(false), parsed(false)
- , vmFunction(0) {}
+ , vmFunction(0), parseAsBinding(false) {}
Script(ExecutionEngine *engine, Object *qml, const QString &sourceCode, const QString &source = QString(), int line = 1, int column = 0)
: sourceFile(source), line(line), column(column), sourceCode(sourceCode)
, scope(engine->rootContext), strictMode(true), inheritContext(true), parsed(false)
- , qml(Value::fromObject(qml)), vmFunction(0) {}
+ , qml(Value::fromObject(qml)), vmFunction(0), parseAsBinding(true) {}
QString sourceFile;
int line;
int column;
bool parsed;
QV4::PersistentValue qml;
Function *vmFunction;
+ bool parseAsBinding;
void parse();
Value run();