| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtScript module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include "config.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/config.h`/ |
| 41 | #include "qscriptstaticscopeobject_p.h"cxx . . $ `<file>/src/script/bridge/qscriptstaticscopeobject_p.h`/ |
| 42 | |
| 43 | namespace JSCcxx . . $ `<built-in>:463:9`! |
| 44 | { |
| 45 | ASSERT_CLASS_FITS_IN_CELLcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/Collector.h:42:9`!(QT_PREPEND_NAMESPACEcxx . . $ `<external>/15045578679651060896/qglobal.h:146:10`!(QScriptStaticScopeObject)); |
| 46 | } |
| 47 | |
| 48 | QT_BEGIN_NAMESPACEcxx . . $ `<external>/15045578679651060896/qglobal.h:148:10`! |
| 49 | |
| 50 | /*! |
| 51 | \class QScriptStaticScopeObject |
| 52 | \internal |
| 53 | |
| 54 | Represents a static scope object. |
| 55 | |
| 56 | This class allows the VM to determine at JS script compile time whether |
| 57 | the object has a given property or not. If the object has the property, |
| 58 | a fast, index-based read/write operation will be used. If the object |
| 59 | doesn't have the property, the compiler knows it can safely skip this |
| 60 | object when dynamically resolving the property. Either way, this can |
| 61 | greatly improve performance. |
| 62 | |
| 63 | \sa QScriptContext::pushScope() |
| 64 | */ |
| 65 | |
| 66 | const JSCcxx . . $ `<built-in>:463:9`!::ClassInfocxx . . $ QTJSC/ClassInfo# QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::infocxx . . $ QScriptStaticScopeObject#info. = { "QScriptStaticScopeObject", 0, 0, 0 }; |
| 67 | |
| 68 | /*! |
| 69 | Creates a static scope object with a fixed set of undeletable properties. |
| 70 | |
| 71 | It's not possible to add new properties to the object after construction. |
| 72 | */ |
| 73 | QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#QScriptStaticScopeObject(523eeb1dd2656949).(WTFcxx . . $ `<built-in>:467:9`!::NonNullPassRefPtrcxx . . $ QTWTF/NonNullPassRefPtr#<JSCcxx . . $ `<built-in>:463:9`!::Structurecxx . . $ QTJSC/Structure#> structure, |
| 74 | int propertyCount, const PropertyInfocxx . . $ QScriptStaticScopeObject#PropertyInfo#* props) |
| 75 | : JSCcxx . . $ `<built-in>:463:9`!::JSVariableObjectcxx . . $ QTJSC/JSVariableObject#(structure, new Datacxx . . $ QScriptStaticScopeObject#Data#(/*canGrow=*/false)) |
| 76 | { |
| 77 | int index = growRegisterArraycxx . . $ QScriptStaticScopeObject#growRegisterArray(7864480464b09eea).(propertyCount); |
| 78 | for (int i = 0; i < propertyCount; ++i, --index) { |
| 79 | const PropertyInfocxx . . $ QScriptStaticScopeObject#PropertyInfo#& prop = props[i]; |
| 80 | JSCcxx . . $ `<built-in>:463:9`!::SymbolTableEntrycxx . . $ QTJSC/SymbolTableEntry# entrycxx . . $ QTJSC/SymbolTableEntry#SymbolTableEntry(c8dafc4a64bf4a1c).(index, prop.attributescxx . . $ QScriptStaticScopeObject#PropertyInfo#attributes.); |
| 81 | symbolTablecxx . . $ QTJSC/JSVariableObject#symbolTable(322f943048330fa4).().add(prop.identifier.ustring().rep(), entry); |
| 82 | registerAtcxx . . $ QTJSC/JSVariableObject#registerAt(a26ae29072816692).(index) = prop.valuecxx . . $ QScriptStaticScopeObject#PropertyInfo#value.; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /*! |
| 87 | Creates an empty static scope object. |
| 88 | |
| 89 | Properties can be added to the object after construction, either by |
| 90 | calling QScriptValue::setProperty(), or by pushing the object on the |
| 91 | scope chain; variable declarations ("var" statements) and function |
| 92 | declarations in JavaScript will create properties on the scope object. |
| 93 | |
| 94 | Note that once the scope object has been used in a closure and the |
| 95 | resulting function has been compiled, it's no longer safe to add |
| 96 | properties to the scope object (because the VM will bypass this |
| 97 | object the next time the function is executed). |
| 98 | */ |
| 99 | QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#QScriptStaticScopeObject(9678d77265d996b).(WTFcxx . . $ `<built-in>:467:9`!::NonNullPassRefPtrcxx . . $ QTWTF/NonNullPassRefPtr#<JSCcxx . . $ `<built-in>:463:9`!::Structurecxx . . $ QTJSC/Structure#> structure) |
| 100 | : JSCcxx . . $ `<built-in>:463:9`!::JSVariableObjectcxx . . $ QTJSC/JSVariableObject#(structure, new Datacxx . . $ QScriptStaticScopeObject#Data#(/*canGrow=*/true)) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::~cxx . . $ QScriptStaticScopeObject#`~QScriptStaticScopeObject`(49f6e7a06ebc5aa8).QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#() |
| 105 | { |
| 106 | delete d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).(); |
| 107 | } |
| 108 | |
| 109 | bool QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::getOwnPropertySlotcxx . . $ QScriptStaticScopeObject#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(JSCcxx . . $ `<built-in>:463:9`!::ExecStatecxx . . $ QTJSC/ExecState#*, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSCcxx . . $ `<built-in>:463:9`!::PropertySlotcxx . . $ QTJSC/PropertySlot#& slot) |
| 110 | { |
| 111 | return symbolTableGetcxx . . $ QTJSC/JSVariableObject#symbolTableGet(731403b11dc42711).(propertyName, slot); |
| 112 | } |
| 113 | |
| 114 | bool QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::getOwnPropertyDescriptorcxx . . $ QScriptStaticScopeObject#getOwnPropertyDescriptor(dce4ef7012294c32).(JSCcxx . . $ `<built-in>:463:9`!::ExecStatecxx . . $ QTJSC/ExecState#*, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSCcxx . . $ `<built-in>:463:9`!::PropertyDescriptorcxx . . $ QTJSC/PropertyDescriptor#& descriptor) |
| 115 | { |
| 116 | return symbolTableGetcxx . . $ QTJSC/JSVariableObject#symbolTableGet(731403b11dc42711).(propertyName, descriptor); |
| 117 | } |
| 118 | |
| 119 | void QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::putWithAttributescxx . . $ QScriptStaticScopeObject#putWithAttributes(3dd2e6313723688d).(JSCcxx . . $ `<built-in>:463:9`!::ExecStatecxx . . $ QTJSC/ExecState#* exec, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier# &propertyName, JSCcxx . . $ `<built-in>:463:9`!::JSValuecxx . . $ QTJSC/JSValue# value, unsigned attributes) |
| 120 | { |
| 121 | if (symbolTablePutWithAttributescxx . . $ QTJSC/JSVariableObject#symbolTablePutWithAttributes(689229d65cb128e1).(propertyName, value, attributes)) |
| 122 | return; |
| 123 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(d_ptr()->canGrow); |
| 124 | addSymbolTablePropertycxx . . $ QScriptStaticScopeObject#addSymbolTableProperty(10adf5710ac333de).(propertyName, value, attributes); |
| 125 | } |
| 126 | |
| 127 | void QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::putcxx . . $ QScriptStaticScopeObject#put(dfb3133dafbe9ff4).(JSCcxx . . $ `<built-in>:463:9`!::ExecStatecxx . . $ QTJSC/ExecState#* exec, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSCcxx . . $ `<built-in>:463:9`!::JSValuecxx . . $ QTJSC/JSValue# value, JSCcxx . . $ `<built-in>:463:9`!::PutPropertySlotcxx . . $ QTJSC/PutPropertySlot#&) |
| 128 | { |
| 129 | if (symbolTablePutcxx . . $ QTJSC/JSVariableObject#symbolTablePut(fed57b58e1b3b689).(propertyName, value)) |
| 130 | return; |
| 131 | Q_ASSERTcxx . . $ `<external>/15045578679651060896/qglobal.h:859:13`!(d_ptr()->canGrow); |
| 132 | addSymbolTablePropertycxx . . $ QScriptStaticScopeObject#addSymbolTableProperty(10adf5710ac333de).(propertyName, value, /*attributes=*/0); |
| 133 | } |
| 134 | |
| 135 | bool QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::deletePropertycxx . . $ QScriptStaticScopeObject#deleteProperty(13154ef9bddc9416).(JSCcxx . . $ `<built-in>:463:9`!::ExecStatecxx . . $ QTJSC/ExecState#*, const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#&) |
| 136 | { |
| 137 | return false; |
| 138 | } |
| 139 | |
| 140 | void QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::markChildrencxx . . $ QScriptStaticScopeObject#markChildren(bd9cae851d80a865).(JSCcxx . . $ `<built-in>:463:9`!::MarkStackcxx . . $ QTJSC/MarkStack#& markStack) |
| 141 | { |
| 142 | JSCcxx . . $ `<built-in>:463:9`!::Registercxx . . $ QTJSC/Register#* registerArray = d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).()->registerArray.get(); |
| 143 | if (!registerArray) |
| 144 | return; |
| 145 | markStack.appendValuescxx . . $ QTJSC/MarkStack#appendValues(5ce9403f1fe638b8).(reinterpret_cast<JSCcxx . . $ `<built-in>:463:9`!::JSValuecxx . . $ QTJSC/JSValue#*>(registerArray), d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).()->registerArraySizecxx . . $ QScriptStaticScopeObject#Data#registerArraySize.); |
| 146 | } |
| 147 | |
| 148 | void QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::addSymbolTablePropertycxx . . $ QScriptStaticScopeObject#addSymbolTableProperty(10adf5710ac333de).(const JSCcxx . . $ `<built-in>:463:9`!::Identifiercxx . . $ QTJSC/Identifier#& name, JSCcxx . . $ `<built-in>:463:9`!::JSValuecxx . . $ QTJSC/JSValue# value, unsigned attributes) |
| 149 | { |
| 150 | int index = growRegisterArraycxx . . $ QScriptStaticScopeObject#growRegisterArray(7864480464b09eea).(1); |
| 151 | JSCcxx . . $ `<built-in>:463:9`!::SymbolTableEntrycxx . . $ QTJSC/SymbolTableEntry# newEntrycxx . . $ QTJSC/SymbolTableEntry#SymbolTableEntry(c8dafc4a64bf4a1c).(index, attributes | JSCcxx . . $ `<built-in>:463:9`!::DontDeletecxx . . $ QTJSC/DontDelete.); |
| 152 | symbolTablecxx . . $ QTJSC/JSVariableObject#symbolTable(322f943048330fa4).().add(name.ustringcxx . . $ QTJSC/Identifier#ustring(de21ee9ecbd506fd).().repcxx . . $ QTJSC/UString#rep(eff8ac5d0836371c).(), newEntry); |
| 153 | registerAtcxx . . $ QTJSC/JSVariableObject#registerAt(a26ae29072816692).(index) = value; |
| 154 | } |
| 155 | |
| 156 | /*! |
| 157 | Grows the register array by \a count elements, and returns the offset of |
| 158 | the newly added elements (note that the register file grows downwards, |
| 159 | starting at index -1). |
| 160 | */ |
| 161 | int QScriptStaticScopeObjectcxx . . $ QScriptStaticScopeObject#::growRegisterArraycxx . . $ QScriptStaticScopeObject#growRegisterArray(7864480464b09eea).(int count) |
| 162 | { |
| 163 | size_t oldSize = d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).()->registerArraySizecxx . . $ QScriptStaticScopeObject#Data#registerArraySize.; |
| 164 | size_t newSize = oldSize + count; |
| 165 | JSCcxx . . $ `<built-in>:463:9`!::Registercxx . . $ QTJSC/Register#* registerArray = new JSCcxx . . $ `<built-in>:463:9`!::Registercxx . . $ QTJSC/Register#[newSize]; |
| 166 | if (d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).()->registerArray) |
| 167 | memcpy(registerArray + count, d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).()->registerArray.get(), oldSize * sizeof(JSCcxx . . $ `<built-in>:463:9`!::Registercxx . . $ QTJSC/Register#)); |
| 168 | setRegisterscxx . . $ QTJSC/JSVariableObject#setRegisters(db765aed4a7dcca8).(registerArray + newSize, registerArray); |
| 169 | d_ptrcxx . . $ QScriptStaticScopeObject#d_ptr(8036a331e3719154).()->registerArraySizecxx . . $ QScriptStaticScopeObject#Data#registerArraySize. = newSize; |
| 170 | return -oldSize - 1; |
| 171 | } |
| 172 | |
| 173 | QT_END_NAMESPACEcxx . . $ `<external>/15045578679651060896/qglobal.h:149:10`! |