v8  3.11.10(node0.8.26)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
accessors.h
Go to the documentation of this file.
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  V(ObjectPrototype)
61 
62 // Accessors contains all predefined proxy accessors.
63 
64 class Accessors : public AllStatic {
65  public:
66  // Accessor descriptors.
67 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \
68  static const AccessorDescriptor name;
70 #undef ACCESSOR_DESCRIPTOR_DECLARATION
71 
72  enum DescriptorId {
73 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \
74  k##name,
76 #undef ACCESSOR_DESCRIPTOR_DECLARATION
78  };
79 
80  // Accessor functions called directly from the runtime system.
81  MUST_USE_RESULT static MaybeObject* FunctionGetPrototype(Object* object,
82  void*);
83  MUST_USE_RESULT static MaybeObject* FunctionSetPrototype(JSObject* object,
84  Object* value,
85  void*);
86  static MaybeObject* FunctionGetArguments(Object* object, void*);
87 
88  private:
89  // Accessor functions only used through the descriptor.
90  static MaybeObject* FunctionGetLength(Object* object, void*);
91  static MaybeObject* FunctionGetName(Object* object, void*);
92  static MaybeObject* FunctionGetCaller(Object* object, void*);
93  MUST_USE_RESULT static MaybeObject* ArraySetLength(JSObject* object,
94  Object* value, void*);
95  static MaybeObject* ArrayGetLength(Object* object, void*);
96  static MaybeObject* StringGetLength(Object* object, void*);
97  static MaybeObject* ScriptGetName(Object* object, void*);
98  static MaybeObject* ScriptGetId(Object* object, void*);
99  static MaybeObject* ScriptGetSource(Object* object, void*);
100  static MaybeObject* ScriptGetLineOffset(Object* object, void*);
101  static MaybeObject* ScriptGetColumnOffset(Object* object, void*);
102  static MaybeObject* ScriptGetData(Object* object, void*);
103  static MaybeObject* ScriptGetType(Object* object, void*);
104  static MaybeObject* ScriptGetCompilationType(Object* object, void*);
105  static MaybeObject* ScriptGetLineEnds(Object* object, void*);
106  static MaybeObject* ScriptGetContextData(Object* object, void*);
107  static MaybeObject* ScriptGetEvalFromScript(Object* object, void*);
108  static MaybeObject* ScriptGetEvalFromScriptPosition(Object* object, void*);
109  static MaybeObject* ScriptGetEvalFromFunctionName(Object* object, void*);
110  static MaybeObject* ObjectGetPrototype(Object* receiver, void*);
111  static MaybeObject* ObjectSetPrototype(JSObject* receiver,
112  Object* value,
113  void*);
114 
115  // Helper functions.
116  static Object* FlattenNumber(Object* value);
117  static MaybeObject* IllegalSetter(JSObject*, Object*, void*);
118  static Object* IllegalGetAccessor(Object* object, void*);
119  static MaybeObject* ReadOnlySetAccessor(JSObject*, Object* value, void*);
120 };
121 
122 } } // namespace v8::internal
123 
124 #endif // V8_ACCESSORS_H_
#define ACCESSOR_DESCRIPTOR_DECLARATION(name)
Definition: accessors.h:73
#define MUST_USE_RESULT
Definition: globals.h:360
static MaybeObject * FunctionGetArguments(Object *object, void *)
Definition: accessors.cc:589
#define ACCESSOR_DESCRIPTOR_LIST(V)
Definition: accessors.h:39
static MUST_USE_RESULT MaybeObject * FunctionSetPrototype(JSObject *object, Object *value, void *)
Definition: accessors.cc:476
static MUST_USE_RESULT MaybeObject * FunctionGetPrototype(Object *object, void *)
Definition: accessors.cc:449