⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsglobalobject.h

📁 linux下开源浏览器WebKit的源码,市面上的很多商用浏览器都是移植自WebKit
💻 H
📖 第 1 页 / 共 2 页
字号:
        Structure* callbackObjectStructure() const { return d()->callbackObjectStructure.get(); }        Structure* dateStructure() const { return d()->dateStructure.get(); }        Structure* emptyObjectStructure() const { return d()->emptyObjectStructure.get(); }        Structure* errorStructure() const { return d()->errorStructure.get(); }        Structure* functionStructure() const { return d()->functionStructure.get(); }        Structure* numberObjectStructure() const { return d()->numberObjectStructure.get(); }        Structure* prototypeFunctionStructure() const { return d()->prototypeFunctionStructure.get(); }        Structure* regExpMatchesArrayStructure() const { return d()->regExpMatchesArrayStructure.get(); }        Structure* regExpStructure() const { return d()->regExpStructure.get(); }        Structure* stringObjectStructure() const { return d()->stringObjectStructure.get(); }        void setProfileGroup(unsigned value) { d()->profileGroup = value; }        unsigned profileGroup() const { return d()->profileGroup; }        Debugger* debugger() const { return d()->debugger; }        void setDebugger(Debugger* debugger) { d()->debugger = debugger; }                virtual bool supportsProfiling() const { return false; }                int recursion() { return d()->recursion; }        void incRecursion() { ++d()->recursion; }        void decRecursion() { --d()->recursion; }                ScopeChain& globalScopeChain() { return d()->globalScopeChain; }        virtual bool isGlobalObject() const { return true; }        virtual ExecState* globalExec();        virtual bool shouldInterruptScript() const { return true; }        virtual bool allowsAccessFrom(const JSGlobalObject*) const { return true; }        virtual bool isDynamicScope() const;        HashSet<ProgramCodeBlock*>& codeBlocks() { return d()->codeBlocks; }        void copyGlobalsFrom(RegisterFile&);        void copyGlobalsTo(RegisterFile&);                void resetPrototype(JSValuePtr prototype);        JSGlobalData* globalData() { return d()->globalData.get(); }        JSGlobalObjectData* d() const { return static_cast<JSGlobalObjectData*>(JSVariableObject::d); }        static PassRefPtr<Structure> createStructure(JSValuePtr prototype)        {            return Structure::create(prototype, TypeInfo(ObjectType));        }    protected:        struct GlobalPropertyInfo {            GlobalPropertyInfo(const Identifier& i, JSValuePtr v, unsigned a)                : identifier(i)                , value(v)                , attributes(a)            {            }            const Identifier identifier;            JSValuePtr value;            unsigned attributes;        };        void addStaticGlobals(GlobalPropertyInfo*, int count);    private:        // FIXME: Fold reset into init.        void init(JSObject* thisValue);        void reset(JSValuePtr prototype);        void setRegisters(Register* registers, Register* registerArray, size_t count);        void* operator new(size_t); // can only be allocated with JSGlobalData    };    JSGlobalObject* asGlobalObject(JSValuePtr);    inline JSGlobalObject* asGlobalObject(JSValuePtr value)    {        ASSERT(asObject(value)->isGlobalObject());        return static_cast<JSGlobalObject*>(asObject(value));    }    inline void JSGlobalObject::setRegisters(Register* registers, Register* registerArray, size_t count)    {        JSVariableObject::setRegisters(registers, registerArray);        d()->registerArraySize = count;    }    inline void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)    {        size_t oldSize = d()->registerArraySize;        size_t newSize = oldSize + count;        Register* registerArray = new Register[newSize];        if (d()->registerArray)            memcpy(registerArray + count, d()->registerArray.get(), oldSize * sizeof(Register));        setRegisters(registerArray + newSize, registerArray, newSize);        for (int i = 0, index = -static_cast<int>(oldSize) - 1; i < count; ++i, --index) {            GlobalPropertyInfo& global = globals[i];            ASSERT(global.attributes & DontDelete);            SymbolTableEntry newEntry(index, global.attributes);            symbolTable().add(global.identifier.ustring().rep(), newEntry);            registerAt(index) = global.value;        }    }    inline bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)    {        if (JSVariableObject::getOwnPropertySlot(exec, propertyName, slot))            return true;        return symbolTableGet(propertyName, slot);    }    inline bool JSGlobalObject::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot, bool& slotIsWriteable)    {        if (JSVariableObject::getOwnPropertySlotForWrite(exec, propertyName, slot, slotIsWriteable))            return true;        return symbolTableGet(propertyName, slot, slotIsWriteable);    }    inline JSGlobalObject* ScopeChainNode::globalObject() const    {        const ScopeChainNode* n = this;        while (n->next)            n = n->next;        return asGlobalObject(n->object);    }    inline JSValuePtr Structure::prototypeForLookup(ExecState* exec) const    {        if (typeInfo().type() == ObjectType)            return m_prototype;        if (typeInfo().type() == StringType)            return exec->lexicalGlobalObject()->stringPrototype();        ASSERT(typeInfo().type() == NumberType);        return exec->lexicalGlobalObject()->numberPrototype();    }    inline StructureChain* Structure::prototypeChain(ExecState* exec) const    {        // We cache our prototype chain so our clients can share it.        if (!isValid(exec, m_cachedPrototypeChain.get())) {            JSValuePtr prototype = prototypeForLookup(exec);            m_cachedPrototypeChain = StructureChain::create(prototype.isNull() ? 0 : asObject(prototype)->structure());        }        return m_cachedPrototypeChain.get();    }    inline bool Structure::isValid(ExecState* exec, StructureChain* cachedPrototypeChain) const    {        if (!cachedPrototypeChain)            return false;        JSValuePtr prototype = prototypeForLookup(exec);        RefPtr<Structure>* cachedStructure = cachedPrototypeChain->head();        while(*cachedStructure && !prototype.isNull()) {            if (asObject(prototype)->structure() != *cachedStructure)                return false;            ++cachedStructure;            prototype = asObject(prototype)->prototype();        }        return prototype.isNull() && !*cachedStructure;    }    inline JSGlobalObject* ExecState::dynamicGlobalObject()    {        if (this == lexicalGlobalObject()->globalExec())            return lexicalGlobalObject();        // For any ExecState that's not a globalExec, the         // dynamic global object must be set since code is running        ASSERT(globalData().dynamicGlobalObject);        return globalData().dynamicGlobalObject;    }    class DynamicGlobalObjectScope : Noncopyable {    public:        DynamicGlobalObjectScope(CallFrame* callFrame, JSGlobalObject* dynamicGlobalObject)             : m_dynamicGlobalObjectSlot(callFrame->globalData().dynamicGlobalObject)            , m_savedDynamicGlobalObject(m_dynamicGlobalObjectSlot)        {            m_dynamicGlobalObjectSlot = dynamicGlobalObject;        }        ~DynamicGlobalObjectScope()        {            m_dynamicGlobalObjectSlot = m_savedDynamicGlobalObject;        }    private:        JSGlobalObject*& m_dynamicGlobalObjectSlot;        JSGlobalObject* m_savedDynamicGlobalObject;    };} // namespace JSC#endif // JSGlobalObject_h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -