-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathES5Array.h
More file actions
110 lines (93 loc) · 6.43 KB
/
ES5Array.h
File metadata and controls
110 lines (93 loc) · 6.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
namespace Js
{
class ES5ArrayType : public DynamicType
{
friend class ES5Array;
protected:
ES5ArrayType(DynamicType * type);
};
}
AUTO_REGISTER_RECYCLER_OBJECT_DUMPER(Js::ES5ArrayType, &Js::RecyclableObject::DumpObjectFunction);
namespace Js
{
//
// ES5Array supports attribute/getter/setter for index property names.
//
// This implementation depends on v-table swapping so that a normal JavascriptArray instance can be
// converted to an ES5Array at runtime when ES5 attribute/getter/setter support is needed. As a result,
// this class can't add any new fields to JavascriptArray. The extra index attribute/getter/setter info
// are maintained in the private ES5ArrayTypeHandler.
//
// ES5Array does not reimplement Array.prototype methods. It depends on JavascriptArray implementations
// to go through generic object route as ES5Array has a new TypeId and is treated as an object.
//
class ES5Array : public JavascriptArray
{
protected:
DEFINE_VTABLE_CTOR(ES5Array, JavascriptArray);
DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(ES5Array);
private:
bool GetPropertyBuiltIns(PropertyId propertyId, Var* value, BOOL* result);
bool SetPropertyBuiltIns(PropertyId propertyId, Var value, PropertyOperationFlags flags, BOOL* result);
bool GetSetterBuiltIns(PropertyId propertyId, PropertyValueInfo* info, DescriptorFlags* result);
public:
static uint32 ToLengthValue(Var value, ScriptContext* scriptContext);
bool IsLengthWritable() const;
virtual DynamicType* DuplicateType() override;
// Enumerate
BOOL IsValidDescriptorToken(void * descriptorValidationToken) const;
uint32 GetNextDescriptor(uint32 key, IndexPropertyDescriptor** descriptor, void ** descriptorValidationToken);
BOOL GetDescriptor(uint32 index, Js::IndexPropertyDescriptor **ppDescriptor);
//
// To skip JavascriptArray overrides
//
virtual PropertyQueryFlags HasPropertyQuery(PropertyId propertyId, _Inout_opt_ PropertyValueInfo* info) override;
virtual BOOL IsWritable(PropertyId propertyId) override;
virtual BOOL SetEnumerable(PropertyId propertyId, BOOL value) override;
virtual BOOL SetWritable(PropertyId propertyId, BOOL value) override;
virtual BOOL SetConfigurable(PropertyId propertyId, BOOL value) override;
virtual BOOL SetAttributes(PropertyId propertyId, PropertyAttributes attributes) override;
virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, JavascriptString* propertyNameString, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
virtual PropertyQueryFlags GetPropertyReferenceQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;
virtual BOOL SetProperty(PropertyId propertyId, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
virtual BOOL SetProperty(JavascriptString* propertyNameString, Var value, PropertyOperationFlags flags, PropertyValueInfo* info) override;
virtual BOOL SetPropertyWithAttributes(PropertyId propertyId, Var value, PropertyAttributes attributes, PropertyValueInfo* info, PropertyOperationFlags flags = PropertyOperation_None, SideEffects possibleSideEffects = SideEffects_Any) override;
virtual PropertyQueryFlags HasItemQuery(uint32 index) override;
virtual PropertyQueryFlags GetItemQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
virtual PropertyQueryFlags GetItemReferenceQuery(Var originalInstance, uint32 index, Var* value, ScriptContext * requestContext) override;
virtual BOOL SetItem(uint32 index, Var value, PropertyOperationFlags flags) override;
virtual BOOL DeleteItem(uint32 index, PropertyOperationFlags flags) override;
virtual DescriptorFlags GetSetter(PropertyId propertyId, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
virtual DescriptorFlags GetSetter(JavascriptString* propertyNameString, Var *setterValue, PropertyValueInfo* info, ScriptContext* requestContext) override;
virtual DescriptorFlags GetItemSetter(uint32 index, Var* setterValue, ScriptContext* requestContext) override;
virtual BOOL SetAccessors(PropertyId propertyId, Var getter, Var setter, PropertyOperationFlags flags) override;
virtual BOOL PreventExtensions() override;
virtual BOOL Seal() override;
virtual BOOL Freeze() override;
virtual BOOL GetEnumerator(JavascriptStaticEnumerator * enumerator, EnumeratorFlags flags, ScriptContext* requestContext, EnumeratorCache * enumeratorCache = nullptr) override;
// objectArray support
virtual BOOL SetItemWithAttributes(uint32 index, Var value, PropertyAttributes attributes) override;
virtual BOOL SetItemAttributes(uint32 index, PropertyAttributes attributes) override;
virtual BOOL SetItemAccessors(uint32 index, Var getter, Var setter) override;
virtual BOOL IsObjectArrayFrozen() override;
virtual JavascriptEnumerator * GetIndexEnumerator(EnumeratorFlags flags, ScriptContext* requestContext) override;
// for SCA
virtual BOOL IsItemEnumerable(uint32 index) override;
#if ENABLE_TTD
public:
virtual void MarkVisitKindSpecificPtrs(TTD::SnapshotExtractor* extractor) override;
virtual TTD::NSSnapObjects::SnapObjectType GetSnapTag_TTD() const override;
virtual void ExtractSnapObjectDataInto(TTD::NSSnapObjects::SnapObject* objData, TTD::SlabAllocator& alloc) override;
#endif
};
template <> inline bool VarIsImpl<ES5Array>(RecyclableObject* instance)
{
return JavascriptOperators::GetTypeId(instance) == TypeIds_ES5Array;
}
}
AUTO_REGISTER_RECYCLER_OBJECT_DUMPER(Js::ES5Array, &Js::RecyclableObject::DumpObjectFunction);