$$PWD/qv4instr_moth_p.h \
$$PWD/qv4isel_moth_p.h \
$$PWD/qv4isel_util_p.h \
- $$PWD/qv4ssa_p.h
+ $$PWD/qv4ssa_p.h \
+ $$PWD/qv4regalloc_p.h
SOURCES += \
+ $$PWD/qv4compileddata.cpp \
+ $$PWD/qv4compiler.cpp \
$$PWD/qv4codegen.cpp \
$$PWD/qv4instr_moth.cpp \
$$PWD/qv4isel_masm.cpp \
void Codegen::throwSyntaxError(const SourceLocation &loc, const QString &detail)
{
- QV4::DiagnosticMessage *msg = new QV4::DiagnosticMessage;
- msg->fileName = _module->fileName;
- msg->offset = loc.begin();
- msg->startLine = loc.startLine;
- msg->startColumn = loc.startColumn;
- msg->message = detail;
- if (_context)
- _context->throwSyntaxError(msg);
- else if (_errorHandler)
- _errorHandler->syntaxError(msg);
- else
- Q_ASSERT(!"No error handler available.");
+ QQmlError error;
- error.setUrl(QUrl::fromLocalFile(_fileName));
++ error.setUrl(QUrl::fromLocalFile(_module->fileName));
+ error.setDescription(detail);
+ error.setLine(loc.startLine);
+ error.setColumn(loc.startColumn);
+ _errors << error;
}
void Codegen::throwReferenceError(const SourceLocation &loc, const QString &detail)
{
- if (_context)
- _context->throwReferenceError(QV4::Value::fromString(_context, detail), _module->fileName, loc.startLine);
- else if (_errorHandler)
- throwSyntaxError(loc, detail);
- else
- Q_ASSERT(!"No error handler available.");
+ QQmlError error;
- error.setUrl(QUrl::fromLocalFile(_fileName));
++ error.setUrl(QUrl::fromLocalFile(_module->fileName));
+ error.setDescription(detail);
+ error.setLine(loc.startLine);
+ error.setColumn(loc.startColumn);
+ _errors << error;
+}
+
+void RuntimeCodegen::throwSyntaxError(const AST::SourceLocation &loc, const QString &detail)
+{
- context->throwSyntaxError(detail, _fileName, loc.startLine, loc.startColumn);
++ context->throwSyntaxError(detail, _module->fileName, loc.startLine, loc.startColumn);
+}
+
+void RuntimeCodegen::throwReferenceError(const AST::SourceLocation &loc, const QString &detail)
+{
- context->throwReferenceError(detail, _fileName, loc.startLine, loc.startColumn);
++ context->throwReferenceError(detail, _module->fileName, loc.startLine, loc.startColumn);
}
virtual bool visit(AST::UiSourceElement *ast);
void throwSyntaxErrorOnEvalOrArgumentsInStrictMode(V4IR::Expr* expr, const AST::SourceLocation &loc);
+ virtual void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail);
+ virtual void throwReferenceError(const AST::SourceLocation &loc, const QString &detail);
- void throwSyntaxError(const AST::SourceLocation &loc, const QString &detail);
- void throwReferenceError(const AST::SourceLocation &loc, const QString &detail);
+ QList<QQmlError> errors();
-private:
+protected:
- QString _fileName;
Result _expr;
QString _property;
UiMember _uiMember;
generateFunctionCall(Assembler::Void, __qmljs_builtin_define_object_literal, Assembler::ContextRegister,
Assembler::PointerToValue(result), baseAddressForCallArguments(),
- Assembler::TrustedImmPtr(klass));
+ Assembler::TrustedImm32(classId));
}
+void InstructionSelection::callBuiltinSetupArgumentObject(V4IR::Temp *result)
+{
+ generateFunctionCall(Assembler::Void, __qmljs_builtin_setup_arguments_object, Assembler::ContextRegister,
+ Assembler::PointerToValue(result));
+}
+
void InstructionSelection::callValue(V4IR::Temp *value, V4IR::ExprList *args, V4IR::Temp *result)
{
int argc = prepareVariableArguments(args);
void InstructionSelection::convertType(V4IR::Temp *source, V4IR::Temp *target)
{
// FIXME: do something more useful with this info
- copyValue(source, target);
+ if (target->type & V4IR::NumberType && !(source->type & V4IR::NumberType))
+ unop(V4IR::OpUPlus, source, target);
+ else
+ copyValue(source, target);
}
- String *InstructionSelection::identifier(const QString &s)
- {
- String *str = engine()->newIdentifier(s);
- _vmFunction->identifiers.append(str);
- return str;
- }
-
void InstructionSelection::constructActivationProperty(V4IR::Name *func, V4IR::ExprList *args, V4IR::Temp *result)
{
assert(func != 0);
return squeezed;
}
- QV4::String *InstructionSelection::identifier(const QString &s)
- {
- QV4::String *str = engine()->newIdentifier(s);
- _vmFunction->identifiers.append(str);
- return str;
- }
-
-Instr::Param InstructionSelection::getParam(V4IR::Expr *e) {
- typedef Instr::Param Param;
+Param InstructionSelection::getParam(V4IR::Expr *e) {
+ typedef Param Param;
assert(e);
if (V4IR::Const *c = e->asConst()) {
struct ExecutionEngine;
struct DeclarativeEnvironment;
struct Lookup;
-struct Q_QML_EXPORT DiagnosticMessage
-{
- enum { Error, Warning };
-
- QString fileName;
- quint32 offset;
- quint32 length;
- quint32 startLine;
- unsigned startColumn: 31;
- unsigned type: 1;
- QString message;
- DiagnosticMessage *next;
-
- DiagnosticMessage();
- ~DiagnosticMessage();
- String *buildFullMessage(ExecutionContext *ctx) const;
-};
-
+
+ namespace CompiledData {
+ struct CompilationUnit;
+ struct Function;
+ };
+
struct CallContext;
struct Q_QML_EXPORT ExecutionContext
delete memoryManager;
delete m_qmlExtensions;
emptyClass->destroy();
- delete identifierTable;
delete bumperPointerAllocator;
delete regExpCache;
- UnwindHelper::deregisterFunctions(functions);
delete regExpAllocator;
delete executableAllocator;
}
QQmlJS::V4IR::Module module;
- QQmlJS::Codegen cg(v4->current, f->strictMode);
+ QQmlJS::RuntimeCodegen cg(v4->current, f->strictMode);
- QQmlJS::V4IR::Function *irf = cg(QString(), function, fe, &module);
+ cg(QString(), function, fe, &module);
- QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(v4, &module));
- QV4::Function *vmf = isel->vmFunction(irf);
+ QScopedPointer<QQmlJS::EvalInstructionSelection> isel(v4->iselFactory->create(v4->executableAllocator, &module));
+ QV4::CompiledData::CompilationUnit *compilationUnit = isel->compile();
+ QV4::Function *vmf = compilationUnit->linkToEngine(v4);
return Value::fromObject(v4->newScriptFunction(v4->rootContext, vmf));
}
}
}
+int __qmljs_value_to_int32(const Value &value)
+{
+ return value.toInt32();
+}
+
+int __qmljs_double_to_int32(double d)
+{
+ return Value::toInt32(d);
+}
+
+unsigned __qmljs_value_to_uint32(const Value &value)
+{
+ return value.toUInt32();
+}
+
+unsigned __qmljs_double_to_uint32(double d)
+{
+ return Value::toUInt32(d);
+}
+
+ void __qmljs_value_from_string(Value *result, String *string)
+ {
+ *result = Value::fromString(string);
+ }
+
+ void __qmljs_lookup_runtime_regexp(ExecutionContext *ctx, Value *result, int id)
+ {
+ *result = ctx->compilationUnit->runtimeRegularExpressions[id];
+ }
+
} // namespace QV4
QT_END_NAMESPACE
void __qmljs_builtin_define_property(QV4::ExecutionContext *ctx, const QV4::Value &object, QV4::String *name, QV4::Value *val);
void __qmljs_builtin_define_array(QV4::ExecutionContext *ctx, QV4::Value *array, QV4::Value *values, uint length);
void __qmljs_builtin_define_getter_setter(QV4::ExecutionContext *ctx, const QV4::Value &object, QV4::String *name, const QV4::Value *getter, const QV4::Value *setter);
- void __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, QV4::Value *result, const QV4::Value *args, QV4::InternalClass *klass);
+ void __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, QV4::Value *result, const QV4::Value *args, int classId);
+void __qmljs_builtin_setup_arguments_object(ExecutionContext *ctx, QV4::Value *result);
+
+ void __qmljs_value_from_string(QV4::Value *result, QV4::String *string);
+ void __qmljs_lookup_runtime_regexp(QV4::ExecutionContext *ctx, QV4::Value *result, int id);
+
// constructors
- void __qmljs_init_closure(QV4::ExecutionContext *ctx, QV4::Value *result, QV4::Function *clos);
- QV4::Function *__qmljs_register_function(QV4::ExecutionContext *ctx, QV4::String *name,
- bool hasDirectEval,
- bool usesArgumentsObject, bool isStrict,
- bool hasNestedFunctions,
- QV4::String **formals, unsigned formalCount,
- QV4::String **locals, unsigned localCount);
+ void __qmljs_init_closure(QV4::ExecutionContext *ctx, QV4::Value *result, int functionId);
// strings
Q_QML_EXPORT double __qmljs_string_to_number(const QString &s);
for (String * const *i = scope->variables(), * const *ei = i + scope->variableCount(); i < ei; ++i)
inheritedLocals.append(*i ? (*i)->toQString() : QString());
- Codegen cg(scope, strictMode);
+ RuntimeCodegen cg(scope, strictMode);
- V4IR::Function *globalIRCode = cg(sourceFile, sourceCode, program, &module,
- parseAsBinding ? QQmlJS::Codegen::QmlBinding : QQmlJS::Codegen::EvalCode, inheritedLocals);
- QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(v4, &module));
+ cg(sourceFile, sourceCode, program, &module,
+ parseAsBinding ? QQmlJS::Codegen::QmlBinding : QQmlJS::Codegen::EvalCode, inheritedLocals);
+ QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(v4->executableAllocator, &module));
if (inheritContext)
isel->setUseFastLookups(false);
- if (globalIRCode) {
- vmFunction = isel->vmFunction(globalIRCode);
- }
+ QV4::CompiledData::CompilationUnit *compilationUnit = isel->compile();
+ vmFunction = compilationUnit->linkToEngine(v4);
}
if (!vmFunction)
MOTH_BEGIN_INSTR(CallBuiltinDefineObjectLiteral)
QV4::Value *args = stack + instr.args;
- __qmljs_builtin_define_object_literal(context, VALUEPTR(instr.result), args, instr.internalClass);
+ __qmljs_builtin_define_object_literal(context, VALUEPTR(instr.result), args, instr.internalClassId);
MOTH_END_INSTR(CallBuiltinDefineObjectLiteral)
+ MOTH_BEGIN_INSTR(CallBuiltinSetupArgumentsObject)
+ __qmljs_builtin_setup_arguments_object(context, VALUEPTR(instr.result));
+ MOTH_END_INSTR(CallBuiltinSetupArgumentsObject)
+
MOTH_BEGIN_INSTR(CreateValue)
Q_ASSERT(instr.args + instr.argc <= stackSize);
QV4::Value *args = stack + instr.args;