OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_DEBUG_LIVEEDIT_H_ | 5 #ifndef V8_DEBUG_LIVEEDIT_H_ |
6 #define V8_DEBUG_LIVEEDIT_H_ | 6 #define V8_DEBUG_LIVEEDIT_H_ |
7 | 7 |
8 | 8 |
9 // Live Edit feature implementation. | 9 // Live Edit feature implementation. |
10 // User should be able to change script on already running VM. This feature | 10 // User should be able to change script on already running VM. This feature |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 void SetField(int field_position, Handle<Object> value) { | 245 void SetField(int field_position, Handle<Object> value) { |
246 Object::SetElement(isolate(), array_, field_position, value, SLOPPY) | 246 Object::SetElement(isolate(), array_, field_position, value, SLOPPY) |
247 .Assert(); | 247 .Assert(); |
248 } | 248 } |
249 | 249 |
250 void SetSmiValueField(int field_position, int value) { | 250 void SetSmiValueField(int field_position, int value) { |
251 SetField(field_position, Handle<Smi>(Smi::FromInt(value), isolate())); | 251 SetField(field_position, Handle<Smi>(Smi::FromInt(value), isolate())); |
252 } | 252 } |
253 | 253 |
254 Handle<Object> GetField(int field_position) { | 254 Handle<Object> GetField(int field_position) { |
255 return Object::GetElement( | 255 return JSReceiver::GetElement(isolate(), array_, field_position) |
256 isolate(), array_, field_position).ToHandleChecked(); | 256 .ToHandleChecked(); |
257 } | 257 } |
258 | 258 |
259 int GetSmiValueField(int field_position) { | 259 int GetSmiValueField(int field_position) { |
260 Handle<Object> res = GetField(field_position); | 260 Handle<Object> res = GetField(field_position); |
261 return Handle<Smi>::cast(res)->value(); | 261 return Handle<Smi>::cast(res)->value(); |
262 } | 262 } |
263 | 263 |
264 private: | 264 private: |
265 Handle<JSArray> array_; | 265 Handle<JSArray> array_; |
266 }; | 266 }; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 326 |
327 | 327 |
328 // Wraps SharedFunctionInfo along with some of its fields for passing it | 328 // Wraps SharedFunctionInfo along with some of its fields for passing it |
329 // back to JavaScript. SharedFunctionInfo object itself is additionally | 329 // back to JavaScript. SharedFunctionInfo object itself is additionally |
330 // wrapped into BlindReference for sanitizing reasons. | 330 // wrapped into BlindReference for sanitizing reasons. |
331 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> { | 331 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> { |
332 public: | 332 public: |
333 static bool IsInstance(Handle<JSArray> array) { | 333 static bool IsInstance(Handle<JSArray> array) { |
334 if (array->length() != Smi::FromInt(kSize_)) return false; | 334 if (array->length() != Smi::FromInt(kSize_)) return false; |
335 Handle<Object> element( | 335 Handle<Object> element( |
336 Object::GetElement(array->GetIsolate(), | 336 JSReceiver::GetElement(array->GetIsolate(), array, kSharedInfoOffset_) |
337 array, | 337 .ToHandleChecked()); |
338 kSharedInfoOffset_).ToHandleChecked()); | |
339 if (!element->IsJSValue()) return false; | 338 if (!element->IsJSValue()) return false; |
340 return Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo(); | 339 return Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo(); |
341 } | 340 } |
342 | 341 |
343 explicit SharedInfoWrapper(Handle<JSArray> array) | 342 explicit SharedInfoWrapper(Handle<JSArray> array) |
344 : JSArrayBasedStruct<SharedInfoWrapper>(array) { | 343 : JSArrayBasedStruct<SharedInfoWrapper>(array) { |
345 } | 344 } |
346 | 345 |
347 void SetProperties(Handle<String> name, | 346 void SetProperties(Handle<String> name, |
348 int start_position, | 347 int start_position, |
349 int end_position, | 348 int end_position, |
350 Handle<SharedFunctionInfo> info); | 349 Handle<SharedFunctionInfo> info); |
351 | 350 |
352 Handle<SharedFunctionInfo> GetInfo(); | 351 Handle<SharedFunctionInfo> GetInfo(); |
353 | 352 |
354 private: | 353 private: |
355 static const int kFunctionNameOffset_ = 0; | 354 static const int kFunctionNameOffset_ = 0; |
356 static const int kStartPositionOffset_ = 1; | 355 static const int kStartPositionOffset_ = 1; |
357 static const int kEndPositionOffset_ = 2; | 356 static const int kEndPositionOffset_ = 2; |
358 static const int kSharedInfoOffset_ = 3; | 357 static const int kSharedInfoOffset_ = 3; |
359 static const int kSize_ = 4; | 358 static const int kSize_ = 4; |
360 | 359 |
361 friend class JSArrayBasedStruct<SharedInfoWrapper>; | 360 friend class JSArrayBasedStruct<SharedInfoWrapper>; |
362 }; | 361 }; |
363 | 362 |
364 } // namespace internal | 363 } // namespace internal |
365 } // namespace v8 | 364 } // namespace v8 |
366 | 365 |
367 #endif /* V8_DEBUG_LIVEEDIT_H_ */ | 366 #endif /* V8_DEBUG_LIVEEDIT_H_ */ |
OLD | NEW |