return EXIT_FAILURE;
}
- QQmlJS::VM::Function *f = QQmlJS::VM::EvalFunction::parseSource(ctx, fn, code, QQmlJS::Codegen::GlobalCode, /*inheritContext =*/ false);
+ QQmlJS::VM::Function *f = QQmlJS::VM::EvalFunction::parseSource(ctx, fn, code, QQmlJS::Codegen::GlobalCode,
+ /*strictMode =*/ false, /*inheritContext =*/ false);
if (!f)
continue;
QStack<Environment *> _envStack;
};
-Codegen::Codegen(VM::ExecutionContext *context)
+Codegen::Codegen(VM::ExecutionContext *context, bool strict)
: _module(0)
, _function(0)
, _block(0)
, _labelledStatement(0)
, _tryCleanup(0)
, _context(context)
- , _strictMode(context->strictMode)
+ , _strictMode(strict)
, _debugger(context->engine->debugger)
, _errorHandler(0)
{
const QString code = args[0].stringValue()->toQString();
bool inheritContext = !ctx->strictMode;
- bool cstrict = ctx->strictMode;
- if (!directCall)
- ctx->strictMode = false;
- QQmlJS::VM::Function *f = parseSource(ctx, QStringLiteral("eval code"),
+ QQmlJS::VM::Function *f = parseSource(context, QStringLiteral("eval code"),
code, QQmlJS::Codegen::EvalCode,
- inheritContext);
- ctx->strictMode = cstrict;
+ (directCall && context->strictMode), inheritContext);
if (!f)
return Value::undefinedValue();
}
// set the correct strict mode flag on the context
- cstrict = ctx->strictMode;
+ bool cstrict = ctx->strictMode;
ctx->strictMode = strict;
Value result = f->code(ctx, f->codeData);
QQmlJS::VM::Function *EvalFunction::parseSource(QQmlJS::VM::ExecutionContext *ctx,
const QString &fileName, const QString &source,
QQmlJS::Codegen::Mode mode,
- bool inheritContext)
+ bool strictMode, bool inheritContext)
{
using namespace QQmlJS;
for (String **i = ctx->variables(), **ei = i + ctx->variableCount(); i < ei; ++i)
inheritedLocals.append(*i ? (*i)->toQString() : QString());
- Codegen cg(ctx);
+ Codegen cg(ctx, strictMode);
IR::Function *globalIRCode = cg(fileName, program, &module, mode, inheritedLocals);
QScopedPointer<EvalInstructionSelection> isel(ctx->engine->iselFactory->create(vm, &module));
if (globalIRCode)
static QQmlJS::VM::Function *parseSource(QQmlJS::VM::ExecutionContext *ctx,
const QString &fileName,
const QString &source,
- QQmlJS::Codegen::Mode mode,
+ QQmlJS::Codegen::Mode mode, bool strictMode,
bool inheritContext);
virtual Value call(ExecutionContext *context, Value thisObject, Value *args, int argc);