| 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_LIVEEDIT_H_ | 5 #ifndef V8_LIVEEDIT_H_ |
| 6 #define V8_LIVEEDIT_H_ | 6 #define V8_LIVEEDIT_H_ |
| 7 | 7 |
| 8 | 8 |
| 9 | 9 |
| 10 // Live Edit feature implementation. | 10 // Live Edit feature implementation. |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 friend class JSArrayBasedStruct<FunctionInfoWrapper>; | 271 friend class JSArrayBasedStruct<FunctionInfoWrapper>; |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 | 274 |
| 275 // Wraps SharedFunctionInfo along with some of its fields for passing it | 275 // Wraps SharedFunctionInfo along with some of its fields for passing it |
| 276 // back to JavaScript. SharedFunctionInfo object itself is additionally | 276 // back to JavaScript. SharedFunctionInfo object itself is additionally |
| 277 // wrapped into BlindReference for sanitizing reasons. | 277 // wrapped into BlindReference for sanitizing reasons. |
| 278 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> { | 278 class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> { |
| 279 public: | 279 public: |
| 280 static bool IsInstance(Handle<JSArray> array) { | 280 static bool IsInstance(Handle<JSArray> array) { |
| 281 return array->length() == Smi::FromInt(kSize_) && | 281 if (array->length() != Smi::FromInt(kSize_)) return false; |
| 282 Object::GetElement(array->GetIsolate(), array, kSharedInfoOffset_) | 282 Handle<Object> element( |
| 283 .ToHandleChecked()->IsJSValue(); | 283 Object::GetElement(array->GetIsolate(), |
| 284 array, |
| 285 kSharedInfoOffset_).ToHandleChecked()); |
| 286 if (!element->IsJSValue()) return false; |
| 287 return Handle<JSValue>::cast(element)->value()->IsSharedFunctionInfo(); |
| 284 } | 288 } |
| 285 | 289 |
| 286 explicit SharedInfoWrapper(Handle<JSArray> array) | 290 explicit SharedInfoWrapper(Handle<JSArray> array) |
| 287 : JSArrayBasedStruct<SharedInfoWrapper>(array) { | 291 : JSArrayBasedStruct<SharedInfoWrapper>(array) { |
| 288 } | 292 } |
| 289 | 293 |
| 290 void SetProperties(Handle<String> name, | 294 void SetProperties(Handle<String> name, |
| 291 int start_position, | 295 int start_position, |
| 292 int end_position, | 296 int end_position, |
| 293 Handle<SharedFunctionInfo> info); | 297 Handle<SharedFunctionInfo> info); |
| 294 | 298 |
| 295 Handle<SharedFunctionInfo> GetInfo(); | 299 Handle<SharedFunctionInfo> GetInfo(); |
| 296 | 300 |
| 297 private: | 301 private: |
| 298 static const int kFunctionNameOffset_ = 0; | 302 static const int kFunctionNameOffset_ = 0; |
| 299 static const int kStartPositionOffset_ = 1; | 303 static const int kStartPositionOffset_ = 1; |
| 300 static const int kEndPositionOffset_ = 2; | 304 static const int kEndPositionOffset_ = 2; |
| 301 static const int kSharedInfoOffset_ = 3; | 305 static const int kSharedInfoOffset_ = 3; |
| 302 static const int kSize_ = 4; | 306 static const int kSize_ = 4; |
| 303 | 307 |
| 304 friend class JSArrayBasedStruct<SharedInfoWrapper>; | 308 friend class JSArrayBasedStruct<SharedInfoWrapper>; |
| 305 }; | 309 }; |
| 306 | 310 |
| 307 } } // namespace v8::internal | 311 } } // namespace v8::internal |
| 308 | 312 |
| 309 #endif /* V*_LIVEEDIT_H_ */ | 313 #endif /* V*_LIVEEDIT_H_ */ |
| OLD | NEW |