2012-01-25 00:16:07 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifndef V8_ACCESSORS_H_
|
|
|
|
#define V8_ACCESSORS_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/globals.h"
|
2011-05-06 06:50:20 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// The list of accessor descriptors. This is a second-order macro
|
|
|
|
// taking a macro to be applied to all accessor descriptor names.
|
2014-08-25 09:12:22 +00:00
|
|
|
#define ACCESSOR_INFO_LIST(V) \
|
|
|
|
V(ArgumentsIterator) \
|
|
|
|
V(ArrayLength) \
|
|
|
|
V(FunctionArguments) \
|
|
|
|
V(FunctionCaller) \
|
|
|
|
V(FunctionName) \
|
|
|
|
V(FunctionLength) \
|
|
|
|
V(FunctionPrototype) \
|
2014-11-21 10:50:12 +00:00
|
|
|
V(RegExpSource) \
|
2014-08-25 09:12:22 +00:00
|
|
|
V(ScriptColumnOffset) \
|
|
|
|
V(ScriptCompilationType) \
|
|
|
|
V(ScriptContextData) \
|
|
|
|
V(ScriptEvalFromScript) \
|
|
|
|
V(ScriptEvalFromScriptPosition) \
|
|
|
|
V(ScriptEvalFromFunctionName) \
|
|
|
|
V(ScriptId) \
|
|
|
|
V(ScriptLineEnds) \
|
|
|
|
V(ScriptLineOffset) \
|
|
|
|
V(ScriptName) \
|
|
|
|
V(ScriptSource) \
|
|
|
|
V(ScriptType) \
|
|
|
|
V(ScriptSourceUrl) \
|
|
|
|
V(ScriptSourceMappingUrl) \
|
2014-04-16 14:30:58 +00:00
|
|
|
V(StringLength)
|
2014-04-15 13:25:17 +00:00
|
|
|
|
2008-08-27 13:47:52 +00:00
|
|
|
// Accessors contains all predefined proxy accessors.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
class Accessors : public AllStatic {
|
|
|
|
public:
|
|
|
|
// Accessor descriptors.
|
2014-04-15 13:25:17 +00:00
|
|
|
#define ACCESSOR_INFO_DECLARATION(name) \
|
|
|
|
static void name##Getter( \
|
2014-08-20 15:25:13 +00:00
|
|
|
v8::Local<v8::Name> name, \
|
2014-04-15 13:25:17 +00:00
|
|
|
const v8::PropertyCallbackInfo<v8::Value>& info); \
|
|
|
|
static void name##Setter( \
|
2014-08-20 15:25:13 +00:00
|
|
|
v8::Local<v8::Name> name, \
|
2014-04-15 13:25:17 +00:00
|
|
|
v8::Local<v8::Value> value, \
|
|
|
|
const v8::PropertyCallbackInfo<void>& info); \
|
|
|
|
static Handle<AccessorInfo> name##Info( \
|
|
|
|
Isolate* isolate, \
|
|
|
|
PropertyAttributes attributes);
|
|
|
|
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
|
|
|
|
#undef ACCESSOR_INFO_DECLARATION
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
enum DescriptorId {
|
2014-04-15 13:25:17 +00:00
|
|
|
#define ACCESSOR_INFO_DECLARATION(name) \
|
|
|
|
k##name##Getter, \
|
|
|
|
k##name##Setter,
|
|
|
|
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
|
|
|
|
#undef ACCESSOR_INFO_DECLARATION
|
2008-07-03 15:10:15 +00:00
|
|
|
descriptorCount
|
|
|
|
};
|
|
|
|
|
|
|
|
// Accessor functions called directly from the runtime system.
|
2014-10-14 14:46:11 +00:00
|
|
|
MUST_USE_RESULT static MaybeHandle<Object> FunctionSetPrototype(
|
|
|
|
Handle<JSFunction> object, Handle<Object> value);
|
2013-08-16 21:27:11 +00:00
|
|
|
static Handle<Object> FunctionGetArguments(Handle<JSFunction> object);
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2012-07-09 08:59:03 +00:00
|
|
|
// Accessor infos.
|
|
|
|
static Handle<AccessorInfo> MakeModuleExport(
|
|
|
|
Handle<String> name, int index, PropertyAttributes attributes);
|
|
|
|
|
2013-09-25 08:19:35 +00:00
|
|
|
// Returns true for properties that are accessors to object fields.
|
|
|
|
// If true, *object_offset contains offset of object field.
|
2014-02-04 12:44:15 +00:00
|
|
|
template <class T>
|
|
|
|
static bool IsJSObjectFieldAccessor(typename T::TypeHandle type,
|
2014-08-11 12:57:25 +00:00
|
|
|
Handle<Name> name,
|
2014-02-04 12:44:15 +00:00
|
|
|
int* object_offset);
|
2013-09-25 08:19:35 +00:00
|
|
|
|
2014-04-29 10:59:14 +00:00
|
|
|
static Handle<AccessorInfo> MakeAccessor(
|
|
|
|
Isolate* isolate,
|
2014-08-20 15:25:13 +00:00
|
|
|
Handle<Name> name,
|
|
|
|
AccessorNameGetterCallback getter,
|
|
|
|
AccessorNameSetterCallback setter,
|
2014-04-29 10:59:14 +00:00
|
|
|
PropertyAttributes attributes);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-05-28 09:58:27 +00:00
|
|
|
static Handle<ExecutableAccessorInfo> CloneAccessor(
|
|
|
|
Isolate* isolate,
|
|
|
|
Handle<ExecutableAccessorInfo> accessor);
|
|
|
|
|
|
|
|
|
2014-04-29 10:59:14 +00:00
|
|
|
private:
|
2008-07-03 15:10:15 +00:00
|
|
|
// Helper functions.
|
2013-11-05 13:47:51 +00:00
|
|
|
static Handle<Object> FlattenNumber(Isolate* isolate, Handle<Object> value);
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_ACCESSORS_H_
|