説明を見る。00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef V8_HANDLES_H_
00029 #define V8_HANDLES_H_
00030
00031 namespace v8 { namespace internal {
00032
00033
00034
00035
00036
00037
00038
00039 template<class T>
00040 class Handle {
00041 public:
00042 INLINE(Handle(T** location)) { location_ = location; }
00043 INLINE(explicit Handle(T* obj));
00044
00045 INLINE(Handle()) : location_(NULL) {}
00046
00047
00048
00049 template <class S> Handle(Handle<S> handle) {
00050 #ifdef DEBUG
00051 T* a = NULL;
00052 S* b = NULL;
00053 a = b;
00054 USE(a);
00055 #endif
00056 location_ = reinterpret_cast<T**>(handle.location());
00057 }
00058
00059 INLINE(T* operator ->() const) { return operator*(); }
00060
00061
00062 bool is_identical_to(const Handle<T> other) const {
00063 return operator*() == *other;
00064 }
00065
00066
00067 INLINE(T* operator*() const);
00068
00069
00070 T** location() const {
00071 ASSERT(location_ == NULL ||
00072 reinterpret_cast<Address>(*location_) != kZapValue);
00073 return location_;
00074 }
00075
00076 template <class S> static Handle<T> cast(Handle<S> that) {
00077 T::cast(*that);
00078 return Handle<T>(reinterpret_cast<T**>(that.location()));
00079 }
00080
00081 static Handle<T> null() { return Handle<T>(); }
00082 bool is_null() {return location_ == NULL; }
00083
00084
00085
00086 inline Handle<T> EscapeFrom(HandleScope* scope);
00087
00088 private:
00089 T** location_;
00090 };
00091
00092
00093
00094
00095
00096
00097
00098
00099 void NormalizeProperties(Handle<JSObject> object);
00100 void NormalizeElements(Handle<JSObject> object);
00101 void TransformToFastProperties(Handle<JSObject> object,
00102 int unused_property_fields);
00103 void FlattenString(Handle<String> str);
00104
00105 Handle<Object> SetProperty(Handle<JSObject> object,
00106 Handle<String> key,
00107 Handle<Object> value,
00108 PropertyAttributes attributes);
00109
00110 Handle<Object> SetProperty(Handle<Object> object,
00111 Handle<Object> key,
00112 Handle<Object> value,
00113 PropertyAttributes attributes);
00114
00115 Handle<Object> IgnoreAttributesAndSetLocalProperty(Handle<JSObject> object,
00116 Handle<String> key,
00117 Handle<Object> value,
00118 PropertyAttributes attributes);
00119
00120 Handle<Object> SetPropertyWithInterceptor(Handle<JSObject> object,
00121 Handle<String> key,
00122 Handle<Object> value,
00123 PropertyAttributes attributes);
00124
00125 Handle<Object> SetElement(Handle<JSObject> object,
00126 uint32_t index,
00127 Handle<Object> value);
00128
00129 Handle<Object> GetProperty(Handle<JSObject> obj,
00130 const char* name);
00131
00132 Handle<Object> GetProperty(Handle<Object> obj,
00133 Handle<Object> key);
00134
00135 Handle<Object> GetPropertyWithInterceptor(Handle<JSObject> receiver,
00136 Handle<JSObject> holder,
00137 Handle<String> name,
00138 PropertyAttributes* attributes);
00139
00140 Handle<Object> GetPrototype(Handle<Object> obj);
00141
00142 Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
00143 Handle<Object> DeleteProperty(Handle<JSObject> obj, Handle<String> prop);
00144
00145 Handle<Object> LookupSingleCharacterStringFromCode(uint32_t index);
00146
00147 Handle<JSObject> Copy(Handle<JSObject> obj);
00148
00149
00150
00151 Handle<JSValue> GetScriptWrapper(Handle<Script> script);
00152
00153
00154
00155 v8::Handle<v8::Array> GetKeysForNamedInterceptor(Handle<JSObject> receiver,
00156 Handle<JSObject> object);
00157 v8::Handle<v8::Array> GetKeysForIndexedInterceptor(Handle<JSObject> receiver,
00158 Handle<JSObject> object);
00159
00160
00161 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object);
00162 Handle<JSArray> GetKeysFor(Handle<JSObject> object);
00163 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object);
00164
00165
00166
00167 Handle<FixedArray> UnionOfKeys(Handle<FixedArray> first,
00168 Handle<FixedArray> second);
00169
00170 Handle<String> SubString(Handle<String> str, int start, int end);
00171
00172
00173
00174 void SetExpectedNofProperties(Handle<JSFunction> func, int nof);
00175
00176
00177 void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value);
00178
00179
00180 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
00181 int estimate);
00182 void SetExpectedNofPropertiesFromEstimate(Handle<JSFunction> func,
00183 int estimate);
00184
00185
00186 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
00187 Handle<JSFunction> constructor,
00188 Handle<JSGlobalProxy> global);
00189
00190 Handle<Object> SetPrototype(Handle<JSFunction> function,
00191 Handle<Object> prototype);
00192
00193
00194
00195
00196 enum ClearExceptionFlag { KEEP_EXCEPTION, CLEAR_EXCEPTION };
00197 bool CompileLazyShared(Handle<SharedFunctionInfo> shared,
00198 ClearExceptionFlag flag);
00199 bool CompileLazy(Handle<JSFunction> function, ClearExceptionFlag flag);
00200
00201
00202 void SetupLazy(Handle<JSFunction> fun,
00203 int index,
00204 Handle<Context> compile_context,
00205 Handle<Context> function_context);
00206 void LoadLazy(Handle<JSFunction> fun, bool* pending_exception);
00207
00208 class NoHandleAllocation BASE_EMBEDDED {
00209 public:
00210 #ifndef DEBUG
00211 NoHandleAllocation() {}
00212 ~NoHandleAllocation() {}
00213 #else
00214 inline NoHandleAllocation();
00215 inline ~NoHandleAllocation();
00216 private:
00217 int extensions_;
00218 #endif
00219 };
00220
00221
00222
00223
00224
00225
00226
00227 class OptimizedObjectForAddingMultipleProperties BASE_EMBEDDED {
00228 public:
00229 OptimizedObjectForAddingMultipleProperties(Handle<JSObject> object,
00230 bool condition = true);
00231 ~OptimizedObjectForAddingMultipleProperties();
00232 private:
00233 bool has_been_transformed_;
00234 int unused_property_fields_;
00235 Handle<JSObject> object_;
00236 };
00237
00238
00239 } }
00240
00241 #endif // V8_HANDLES_H_