Fix IR code generation for member expressions
authorRoberto Raggi <roberto.raggi@nokia.com>
Thu, 15 Dec 2011 08:50:51 +0000 (09:50 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 15 Dec 2011 11:17:58 +0000 (12:17 +0100)
The generated code for member expressions (e.g. parent.width) was using
a wrong mix of types from the base object and names from the
current member expression.

Change-Id: I167df285ae44f9dc1538e2b1019998f02a0479a8
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>

src/declarative/qml/v4/qv4irbuilder.cpp

index 389533e..6afe436 100644 (file)
@@ -625,21 +625,23 @@ bool QV4IRBuilder::visit(AST::FieldMemberExpression *ast)
                 break;
 
             case IR::Name::Property: 
-                if (baseName->type == IR::ObjectType) {
-                    QDeclarativePropertyData *data = baseName->property;
-                    if (!data || data->isFunction())
-                        return false; // Don't support methods (or non-existing properties ;)
+                if (baseName->type == IR::ObjectType && baseName->meta && baseName->property->isFinal()) {
+                    QDeclarativePropertyCache *cache = m_engine->cache(baseName->meta);
+                    if (!cache)
+                        return false;
+
+                    if (QDeclarativePropertyData *data = cache->property(name)) {
+                        if (!data->isFinal()) {
+                            if (qmlVerboseCompiler())
+                                qWarning() << "*** non-final property access:"
+                                           << (*baseName->id + QLatin1String(".") + ast->name.toString());
+                            return false; // We don't know enough about this property
+                        }
 
-                    if(!data->isFinal()) {
-                        if (qmlVerboseCompiler())
-                            qWarning() << "*** non-final property access:"
-                                << (*baseName->id + QLatin1String(".") + ast->name.toString());
-                        return false; // We don't know enough about this property
+                        IR::Type irType = irTypeFromVariantType(data->propType, m_engine, baseName->meta);
+                        _expr.code = _block->SYMBOL(baseName, irType, name,
+                                                    baseName->meta, data, line, column);
                     }
-
-                    IR::Type irType = irTypeFromVariantType(data->propType, m_engine, baseName->meta);
-                    _expr.code = _block->SYMBOL(baseName, irType, name,
-                                                baseName->meta, data, line, column);
                 }
                 break;