Changeset 36285 in webkit for trunk/JavaScriptCore/kjs/StructureID.h
- Timestamp:
- Sep 8, 2008, 11:55:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/StructureID.h
r36263 r36285 1 // -*- mode: c++; c-basic-offset: 4 -*-2 1 /* 3 2 * Copyright (C) 2008 Apple Inc. All rights reserved. … … 28 27 #define StructureID_h 29 28 29 #include "JSValue.h" 30 #include "PropertyMap.h" 31 #include "ustring.h" 32 #include <wtf/HashFunctions.h> 33 #include <wtf/HashTraits.h> 30 34 #include <wtf/OwnArrayPtr.h> 31 35 #include <wtf/PassRefPtr.h> 32 36 #include <wtf/RefCounted.h> 33 #include "JSValue.h"34 #include "ustring.h"35 37 36 38 namespace JSC { … … 38 40 class JSValue; 39 41 class StructureIDChain; 42 43 struct TransitionTableHash { 44 typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey; 45 static unsigned hash(const TransitionTableKey& p) 46 { 47 return p.first->computedHash(); 48 } 49 50 static bool equal(const TransitionTableKey& a, const TransitionTableKey& b) 51 { 52 return a == b; 53 } 54 55 static const bool safeToCompareToEmptyOrDeleted = true; 56 }; 57 58 struct TransitionTableHashTraits { 59 typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits; 60 typedef WTF::GenericHashTraits<unsigned> SecondTraits; 61 typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType> TraitType; 62 63 static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero; 64 static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); } 65 66 static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; 67 68 static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); } 69 static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); } 70 }; 40 71 41 72 class StructureID : public RefCounted<StructureID> { … … 45 76 return adoptRef(new StructureID(prototype)); 46 77 } 47 78 48 79 static PassRefPtr<StructureID> changePrototypeTransition(StructureID*, JSValue* prototype); 49 static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& name);80 static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& propertyName, JSValue*, unsigned attributes, bool checkReadOnly, JSObject* slotBase, PutPropertySlot&, PropertyStorage&); 50 81 static PassRefPtr<StructureID> getterSetterTransition(StructureID*); 51 82 static PassRefPtr<StructureID> toDictionaryTransition(StructureID*); … … 63 94 64 95 JSValue* prototype() const { return m_prototype; } 65 96 66 97 void setCachedPrototypeChain(PassRefPtr<StructureIDChain> cachedPrototypeChain) { m_cachedPrototypeChain = cachedPrototypeChain; } 67 98 StructureIDChain* cachedPrototypeChain() const { return m_cachedPrototypeChain.get(); } 68 99 100 const PropertyMap& propertyMap() const { return m_propertyMap; } 101 PropertyMap& propertyMap() { return m_propertyMap; } 102 69 103 private: 70 typedef HashMap<RefPtr<UString::Rep>, StructureID*, IdentifierRepHash, HashTraits<RefPtr<UString::Rep> > > TransitionTable; 71 104 typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey; 105 typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable; 106 72 107 StructureID(JSValue* prototype); 73 108 … … 81 116 RefPtr<StructureID> m_previous; 82 117 UString::Rep* m_nameInPrevious; 118 unsigned m_attributesInPrevious; 83 119 84 120 size_t m_transitionCount; 85 121 TransitionTable m_transitionTable; 122 123 PropertyMap m_propertyMap; 86 124 }; 87 125
Note:
See TracChangeset
for help on using the changeset viewer.