Changeset 34518 in webkit for trunk/JavaScriptCore/kjs/internal.h
- Timestamp:
- Jun 12, 2008, 9:53:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/internal.h
r34355 r34518 3 3 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 4 4 * Copyright (C) 2001 Peter Kelly ([email protected]) 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 25 25 #define INTERNAL_H 26 26 27 #include "JSType.h"28 27 #include "object.h" 29 #include "protect.h"30 #include "scope_chain.h"31 #include "types.h"32 28 #include "ustring.h" 33 34 #include <wtf/Noncopyable.h>35 36 #define I18N_NOOP(s) s37 29 38 30 namespace KJS { 39 31 40 class FunctionPrototype;41 42 // ---------------------------------------------------------------------------43 // Primitive impls44 // ---------------------------------------------------------------------------45 46 32 class StringImp : public JSCell { 47 33 public: 48 StringImp(const UString& v ) : val(v) { Collector::reportExtraMemoryCost(v.cost()); }34 StringImp(const UString& value) : m_value(value) { Collector::reportExtraMemoryCost(value.cost()); } 49 35 enum HasOtherOwnerType { HasOtherOwner }; 50 StringImp(const UString& value, HasOtherOwnerType) : val(value) { } 51 const UString& value() const { return val; } 36 StringImp(const UString& value, HasOtherOwnerType) : m_value(value) { } 37 38 const UString& value() const { return m_value; } 39 40 bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 41 bool getStringPropertySlot(unsigned propertyName, PropertySlot&); 52 42 53 43 private: … … 56 46 virtual JSValue* toPrimitive(ExecState*, JSType preferred = UnspecifiedType) const; 57 47 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value); 58 virtual bool toBoolean(ExecState *exec) const;59 virtual double toNumber(ExecState *exec) const;60 virtual JSObject *toObject(ExecState *exec) const;48 virtual bool toBoolean(ExecState*) const; 49 virtual double toNumber(ExecState*) const; 50 virtual JSObject* toObject(ExecState*) const; 61 51 virtual UString toString(ExecState*) const; 62 52 virtual JSObject* toThisObject(ExecState*) const; 63 53 64 UString val; 54 // Actually getPropertySlot, not getOwnPropertySlot (see JSCell). 55 virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 56 virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); 57 58 static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&); 59 static JSValue* indexGetter(ExecState*, const Identifier&, const PropertySlot&); 60 static JSValue* indexNumericPropertyGetter(ExecState*, unsigned, const PropertySlot&); 61 62 UString m_value; 65 63 }; 66 64 67 // --------------------------------------------------------------------------- 68 // Evaluation 69 // --------------------------------------------------------------------------- 65 ALWAYS_INLINE bool StringImp::getStringPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) 66 { 67 if (propertyName == exec->propertyNames().length) { 68 slot.setCustom(this, lengthGetter); 69 return true; 70 } 71 72 bool isStrictUInt32; 73 unsigned i = propertyName.toStrictUInt32(&isStrictUInt32); 74 if (isStrictUInt32 && i < static_cast<unsigned>(m_value.size())) { 75 slot.setCustomIndex(this, i, indexGetter); 76 return true; 77 } 78 79 return false; 80 } 81 82 ALWAYS_INLINE bool StringImp::getStringPropertySlot(unsigned propertyName, PropertySlot& slot) 83 { 84 if (propertyName < static_cast<unsigned>(m_value.size())) { 85 slot.setCustomNumeric(this, indexNumericPropertyGetter); 86 return true; 87 } 88 89 return false; 90 } 70 91 71 92 } // namespace
Note:
See TracChangeset
for help on using the changeset viewer.