// Copyright 2012 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_ACCESSORS_H_ #define V8_ACCESSORS_H_ #include "src/allocation.h" #include "src/globals.h" namespace v8 { namespace internal { // The list of accessor descriptors. This is a second-order macro // taking a macro to be applied to all accessor descriptor names. #define ACCESSOR_INFO_LIST(V) \ V(ArgumentsIterator) \ V(ArrayLength) \ V(FunctionArguments) \ V(FunctionCaller) \ V(FunctionName) \ V(FunctionLength) \ V(FunctionPrototype) \ V(RegExpSource) \ 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) \ V(StringLength) // Accessors contains all predefined proxy accessors. class Accessors : public AllStatic { public: // Accessor descriptors. #define ACCESSOR_INFO_DECLARATION(name) \ static void name##Getter( \ v8::Local name, \ const v8::PropertyCallbackInfo& info); \ static void name##Setter( \ v8::Local name, \ v8::Local value, \ const v8::PropertyCallbackInfo& info); \ static Handle name##Info( \ Isolate* isolate, \ PropertyAttributes attributes); ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) #undef ACCESSOR_INFO_DECLARATION enum DescriptorId { #define ACCESSOR_INFO_DECLARATION(name) \ k##name##Getter, \ k##name##Setter, ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) #undef ACCESSOR_INFO_DECLARATION descriptorCount }; // Accessor functions called directly from the runtime system. MUST_USE_RESULT static MaybeHandle FunctionSetPrototype( Handle object, Handle value); static Handle FunctionGetArguments(Handle object); // Accessor infos. static Handle MakeModuleExport( Handle name, int index, PropertyAttributes attributes); // Returns true for properties that are accessors to object fields. // If true, *object_offset contains offset of object field. template static bool IsJSObjectFieldAccessor(typename T::TypeHandle type, Handle name, int* object_offset); static Handle MakeAccessor( Isolate* isolate, Handle name, AccessorNameGetterCallback getter, AccessorNameSetterCallback setter, PropertyAttributes attributes); static Handle CloneAccessor( Isolate* isolate, Handle accessor); private: // Helper functions. static Handle FlattenNumber(Isolate* isolate, Handle value); }; } } // namespace v8::internal #endif // V8_ACCESSORS_H_