The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / v8 / src / accessors.h @ f230a1cf

History | View | Annotate | Download (7.6 KB)

1
// Copyright 2012 the V8 project authors. All rights reserved.
2
// Redistribution and use in source and binary forms, with or without
3
// modification, are permitted provided that the following conditions are
4
// met:
5
//
6
//     * Redistributions of source code must retain the above copyright
7
//       notice, this list of conditions and the following disclaimer.
8
//     * Redistributions in binary form must reproduce the above
9
//       copyright notice, this list of conditions and the following
10
//       disclaimer in the documentation and/or other materials provided
11
//       with the distribution.
12
//     * Neither the name of Google Inc. nor the names of its
13
//       contributors may be used to endorse or promote products derived
14
//       from this software without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27

    
28
#ifndef V8_ACCESSORS_H_
29
#define V8_ACCESSORS_H_
30

    
31
#include "allocation.h"
32
#include "v8globals.h"
33

    
34
namespace v8 {
35
namespace internal {
36

    
37
// The list of accessor descriptors. This is a second-order macro
38
// taking a macro to be applied to all accessor descriptor names.
39
#define ACCESSOR_DESCRIPTOR_LIST(V) \
40
  V(FunctionPrototype)              \
41
  V(FunctionLength)                 \
42
  V(FunctionName)                   \
43
  V(FunctionArguments)              \
44
  V(FunctionCaller)                 \
45
  V(ArrayLength)                    \
46
  V(StringLength)                   \
47
  V(ScriptSource)                   \
48
  V(ScriptName)                     \
49
  V(ScriptId)                       \
50
  V(ScriptLineOffset)               \
51
  V(ScriptColumnOffset)             \
52
  V(ScriptData)                     \
53
  V(ScriptType)                     \
54
  V(ScriptCompilationType)          \
55
  V(ScriptLineEnds)                 \
56
  V(ScriptContextData)              \
57
  V(ScriptEvalFromScript)           \
58
  V(ScriptEvalFromScriptPosition)   \
59
  V(ScriptEvalFromFunctionName)
60

    
61
// Accessors contains all predefined proxy accessors.
62

    
63
class Accessors : public AllStatic {
64
 public:
65
  // Accessor descriptors.
66
#define ACCESSOR_DESCRIPTOR_DECLARATION(name) \
67
  static const AccessorDescriptor name;
68
  ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION)
69
#undef ACCESSOR_DESCRIPTOR_DECLARATION
70

    
71
  enum DescriptorId {
72
#define ACCESSOR_DESCRIPTOR_DECLARATION(name) \
73
    k##name,
74
  ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION)
75
#undef ACCESSOR_DESCRIPTOR_DECLARATION
76
    descriptorCount
77
  };
78

    
79
  // Accessor functions called directly from the runtime system.
80
  static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object,
81
                                             Handle<Object> value);
82
  static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object);
83
  static Handle<Object> FunctionGetArguments(Handle<JSFunction> object);
84

    
85
  // Accessor infos.
86
  static Handle<AccessorInfo> MakeModuleExport(
87
      Handle<String> name, int index, PropertyAttributes attributes);
88

    
89
  // Returns true for properties that are accessors to object fields.
90
  // If true, *object_offset contains offset of object field.
91
  static bool IsJSObjectFieldAccessor(
92
      Handle<Map> map, Handle<String> name,
93
      int* object_offset);
94

    
95

    
96
 private:
97
  // Accessor functions only used through the descriptor.
98
  static MaybeObject* FunctionSetPrototype(Isolate* isolate,
99
                                           JSObject* object,
100
                                           Object*,
101
                                           void*);
102
  static MaybeObject* FunctionGetPrototype(Isolate* isolate,
103
                                           Object* object,
104
                                           void*);
105
  static MaybeObject* FunctionGetLength(Isolate* isolate,
106
                                        Object* object,
107
                                        void*);
108
  static MaybeObject* FunctionGetName(Isolate* isolate, Object* object, void*);
109
  static MaybeObject* FunctionGetArguments(Isolate* isolate,
110
                                           Object* object,
111
                                           void*);
112
  static MaybeObject* FunctionGetCaller(Isolate* isolate,
113
                                        Object* object,
114
                                        void*);
115
  static MaybeObject* ArraySetLength(Isolate* isolate,
116
                                     JSObject* object,
117
                                     Object*,
118
                                     void*);
119
  static MaybeObject* ArrayGetLength(Isolate* isolate, Object* object, void*);
120
  static MaybeObject* StringGetLength(Isolate* isolate, Object* object, void*);
121
  static MaybeObject* ScriptGetName(Isolate* isolate, Object* object, void*);
122
  static MaybeObject* ScriptGetId(Isolate* isolate, Object* object, void*);
123
  static MaybeObject* ScriptGetSource(Isolate* isolate, Object* object, void*);
124
  static MaybeObject* ScriptGetLineOffset(Isolate* isolate,
125
                                          Object* object,
126
                                          void*);
127
  static MaybeObject* ScriptGetColumnOffset(Isolate* isolate,
128
                                            Object* object,
129
                                            void*);
130
  static MaybeObject* ScriptGetData(Isolate* isolate, Object* object, void*);
131
  static MaybeObject* ScriptGetType(Isolate* isolate, Object* object, void*);
132
  static MaybeObject* ScriptGetCompilationType(Isolate* isolate,
133
                                               Object* object,
134
                                               void*);
135
  static MaybeObject* ScriptGetLineEnds(Isolate* isolate,
136
                                        Object* object,
137
                                        void*);
138
  static MaybeObject* ScriptGetContextData(Isolate* isolate,
139
                                           Object* object,
140
                                           void*);
141
  static MaybeObject* ScriptGetEvalFromScript(Isolate* isolate,
142
                                              Object* object,
143
                                              void*);
144
  static MaybeObject* ScriptGetEvalFromScriptPosition(Isolate* isolate,
145
                                                      Object* object,
146
                                                      void*);
147
  static MaybeObject* ScriptGetEvalFromFunctionName(Isolate* isolate,
148
                                                    Object* object,
149
                                                    void*);
150

    
151
  // Helper functions.
152
  static Object* FlattenNumber(Isolate* isolate, Object* value);
153
  static MaybeObject* IllegalSetter(Isolate* isolate,
154
                                    JSObject*,
155
                                    Object*,
156
                                    void*);
157
  static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*);
158
  static MaybeObject* ReadOnlySetAccessor(Isolate* isolate,
159
                                          JSObject*,
160
                                          Object* value,
161
                                          void*);
162
};
163

    
164
} }  // namespace v8::internal
165

    
166
#endif  // V8_ACCESSORS_H_