summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativeglobalscriptclass.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright year to 2011.Jason McDonald2011-01-101-1/+1
| | | | Reviewed-by: Trust Me
* Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7Martin Jones2010-06-281-17/+28
|\ | | | | | | | | Conflicts: src/declarative/qml/qdeclarativeglobalscriptclass.cpp
| * Use custom static scopes to improve QML/JavaScript performanceKent Hansen2010-06-251-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a new internal JS object type, QScriptStaticScopeObject, that enables the JS compiler to make more aggressive optimizations of scoped property access. QScriptStaticScopeObject registers all its properties in a symbol table that the JS compiler has access to. If the compiler finds the property in the symbol table, it will generate the fast index-based op_{get,put}_scoped_var bytecodes, rather than the dynamic (slow) op_resolve and friends. If the compiler _doesn't_ find the property in the symbol table, it infers that it's safe to skip the scope object when later resolving the property, which will also improve performance (see op_resolve_skip bytecode). QScriptStaticScopeObject is only safe to use when all relevant properties are known at JS compile time; that is, when a function that has the static scope object in its scope chain is compiled. It's up to the user of the class (e.g. QtDeclarative) to ensure that this constraint is not violated. The API for constructing QScriptStaticScopeObject instances is not public; it lives in QScriptDeclarativeClass for now, an internal class exported for the purpose of QML. The instance is returned as a QScriptValue and can be manipulated like any other JS object (e.g. by QScriptValue::setProperty()). The other part of this commit utilizes QScriptStaticScopeObject in QtDeclarative in the two major places where it's currently possible: 1) QML disallows adding properties to the Global Object. Furthermore, it's not possible for QML IDs and properties to "shadow" global variables. Hence, a QScriptStaticScopeObject can be used to hold all the standard ECMA properties, and this scope object can come _before_ the QML component in the scope chain. This enables binding expressions and scripts to have optimized (direct) access to e.g. Math.sin. 2) Imported scripts can have their properties (resulting from variable declarations ("var" statements) and function declarations) added to a static scope object. This enables functions in the script to have optimized (direct) access to the script's own properties, as well as to global properties such as Math. With this change, it's no longer possible to delete properties of the Global Object, nor delete properties of an imported script. It's a compromise we make in order to make the optimization safe. Task-number: QTBUG-8576 Reviewed-by: Aaron Kennedy Reviewed-by: Olivier Goffart Reviewed-by: Jedrzej Nowacki
* | Disallow global object properties as property namesAaron Kennedy2010-06-251-0/+4
| | | | | | | | QTBUG-11605
* | References to undefined variables throws a ReferenceErrorAaron Kennedy2010-06-231-14/+10
|/ | | | This is consistent with normal JavaScript
* Ensure eval and Function are in the correct scopeAaron Kennedy2010-04-301-5/+15
| | | | QTBUG-10236
* Update #include of private headers in QtDeclarativeThiago Macieira2010-04-021-1/+1
| | | | | Always use private/. The WinSCW compiler doesn't search the current directory, for whatever reason.
* Move JS global scope to top of the QML scope chainAaron Kennedy2010-03-031-5/+10
| | | | QT-2787
* Change class prefix to from QmlXXX to QDeclarativeXXX, QmlGraphicsXXX to ↵Warwick Allison2010-02-241-0/+121
QDeclarativeXXX.