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
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.
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.
28 #ifndef V8_ACCESSORS_H_
29 #define V8_ACCESSORS_H_
31 #include "allocation.h"
32 #include "v8globals.h"
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) \
43 V(FunctionArguments) \
51 V(ScriptColumnOffset) \
54 V(ScriptCompilationType) \
56 V(ScriptContextData) \
57 V(ScriptEvalFromScript) \
58 V(ScriptEvalFromScriptPosition) \
59 V(ScriptEvalFromFunctionName)
61 // Accessors contains all predefined proxy accessors.
63 class Accessors : public AllStatic {
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
72 #define ACCESSOR_DESCRIPTOR_DECLARATION(name) \
74 ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION)
75 #undef ACCESSOR_DESCRIPTOR_DECLARATION
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);
86 static Handle<AccessorInfo> MakeModuleExport(
87 Handle<String> name, int index, PropertyAttributes attributes);
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,
97 // Accessor functions only used through the descriptor.
98 static MaybeObject* FunctionSetPrototype(Isolate* isolate,
102 static MaybeObject* FunctionGetPrototype(Isolate* isolate,
105 static MaybeObject* FunctionGetLength(Isolate* isolate,
108 static MaybeObject* FunctionGetName(Isolate* isolate, Object* object, void*);
109 static MaybeObject* FunctionGetArguments(Isolate* isolate,
112 static MaybeObject* FunctionGetCaller(Isolate* isolate,
115 static MaybeObject* ArraySetLength(Isolate* isolate,
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,
127 static MaybeObject* ScriptGetColumnOffset(Isolate* isolate,
130 static MaybeObject* ScriptGetData(Isolate* isolate, Object* object, void*);
131 static MaybeObject* ScriptGetType(Isolate* isolate, Object* object, void*);
132 static MaybeObject* ScriptGetCompilationType(Isolate* isolate,
135 static MaybeObject* ScriptGetLineEnds(Isolate* isolate,
138 static MaybeObject* ScriptGetContextData(Isolate* isolate,
141 static MaybeObject* ScriptGetEvalFromScript(Isolate* isolate,
144 static MaybeObject* ScriptGetEvalFromScriptPosition(Isolate* isolate,
147 static MaybeObject* ScriptGetEvalFromFunctionName(Isolate* isolate,
152 static Handle<Object> FlattenNumber(Isolate* isolate, Handle<Object> value);
153 static MaybeObject* IllegalSetter(Isolate* isolate,
157 static Object* IllegalGetAccessor(Isolate* isolate, Object* object, void*);
158 static MaybeObject* ReadOnlySetAccessor(Isolate* isolate,
164 } } // namespace v8::internal
166 #endif // V8_ACCESSORS_H_