OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug.h" | 9 #include "src/debug.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 Execution::ToString(isolate, key), Name); | 63 Execution::ToString(isolate, key), Name); |
64 return Handle<Name>::cast(converted); | 64 return Handle<Name>::cast(converted); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 | 68 |
69 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, | 69 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, |
70 Handle<Object> object, | 70 Handle<Object> object, |
71 Handle<Object> key) { | 71 Handle<Object> key) { |
72 if (object->IsUndefined() || object->IsNull()) { | 72 if (object->IsUndefined() || object->IsNull()) { |
73 THROW_NEW_ERROR( | 73 Handle<Object> args[2] = {key, object}; |
74 isolate, | 74 THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_load", |
75 NewTypeError(MessageTemplate::kNonObjectPropertyLoad, key, object), | 75 HandleVector(args, 2)), |
76 Object); | 76 Object); |
77 } | 77 } |
78 | 78 |
79 // Check if the given key is an array index. | 79 // Check if the given key is an array index. |
80 uint32_t index; | 80 uint32_t index; |
81 if (key->ToArrayIndex(&index)) { | 81 if (key->ToArrayIndex(&index)) { |
82 return GetElementOrCharAt(isolate, object, index); | 82 return GetElementOrCharAt(isolate, object, index); |
83 } | 83 } |
84 | 84 |
85 // Convert the key to a name - possibly by calling back into JavaScript. | 85 // Convert the key to a name - possibly by calling back into JavaScript. |
86 Handle<Name> name; | 86 Handle<Name> name; |
87 ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object); | 87 ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object); |
88 | 88 |
89 // Check if the name is trivially convertible to an index and get | 89 // Check if the name is trivially convertible to an index and get |
90 // the element if so. | 90 // the element if so. |
91 if (name->AsArrayIndex(&index)) { | 91 if (name->AsArrayIndex(&index)) { |
92 return GetElementOrCharAt(isolate, object, index); | 92 return GetElementOrCharAt(isolate, object, index); |
93 } else { | 93 } else { |
94 return Object::GetProperty(object, name); | 94 return Object::GetProperty(object, name); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, | 99 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
100 Handle<Object> object, | 100 Handle<Object> object, |
101 Handle<Object> key, | 101 Handle<Object> key, |
102 Handle<Object> value, | 102 Handle<Object> value, |
103 LanguageMode language_mode) { | 103 LanguageMode language_mode) { |
104 if (object->IsUndefined() || object->IsNull()) { | 104 if (object->IsUndefined() || object->IsNull()) { |
105 THROW_NEW_ERROR( | 105 Handle<Object> args[2] = {key, object}; |
106 isolate, | 106 THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store", |
107 NewTypeError(MessageTemplate::kNonObjectPropertyStore, key, object), | 107 HandleVector(args, 2)), |
108 Object); | 108 Object); |
109 } | 109 } |
110 | 110 |
111 if (object->IsJSProxy()) { | 111 if (object->IsJSProxy()) { |
112 Handle<Object> name_object; | 112 Handle<Object> name_object; |
113 if (key->IsSymbol()) { | 113 if (key->IsSymbol()) { |
114 name_object = key; | 114 name_object = key; |
115 } else { | 115 } else { |
116 ASSIGN_RETURN_ON_EXCEPTION(isolate, name_object, | 116 ASSIGN_RETURN_ON_EXCEPTION(isolate, name_object, |
117 Execution::ToString(isolate, key), Object); | 117 Execution::ToString(isolate, key), Object); |
118 } | 118 } |
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1413 isolate, result, | 1413 isolate, result, |
1414 Runtime::DefineObjectProperty(js_object, name, obj_value, attrs)); | 1414 Runtime::DefineObjectProperty(js_object, name, obj_value, attrs)); |
1415 return *result; | 1415 return *result; |
1416 } | 1416 } |
1417 | 1417 |
1418 | 1418 |
1419 // Return property without being observable by accessors or interceptors. | 1419 // Return property without being observable by accessors or interceptors. |
1420 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 1420 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
1421 HandleScope scope(isolate); | 1421 HandleScope scope(isolate); |
1422 DCHECK(args.length() == 2); | 1422 DCHECK(args.length() == 2); |
1423 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 1423 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
1424 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 1424 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
1425 return *JSReceiver::GetDataProperty(object, key); | 1425 return *JSObject::GetDataProperty(object, key); |
1426 } | 1426 } |
1427 | 1427 |
1428 | 1428 |
1429 RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { | 1429 RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { |
1430 SealHandleScope shs(isolate); | 1430 SealHandleScope shs(isolate); |
1431 DCHECK(args.length() == 1); | 1431 DCHECK(args.length() == 1); |
1432 CONVERT_ARG_CHECKED(HeapObject, obj, 0); | 1432 CONVERT_ARG_CHECKED(HeapObject, obj, 0); |
1433 return isolate->heap()->ToBoolean( | 1433 return isolate->heap()->ToBoolean( |
1434 IsFastPackedElementsKind(obj->map()->elements_kind())); | 1434 IsFastPackedElementsKind(obj->map()->elements_kind())); |
1435 } | 1435 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1553 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
1554 | 1554 |
1555 RETURN_FAILURE_ON_EXCEPTION( | 1555 RETURN_FAILURE_ON_EXCEPTION( |
1556 isolate, | 1556 isolate, |
1557 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1557 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
1558 setter, attrs)); | 1558 setter, attrs)); |
1559 return isolate->heap()->undefined_value(); | 1559 return isolate->heap()->undefined_value(); |
1560 } | 1560 } |
1561 } | 1561 } |
1562 } // namespace v8::internal | 1562 } // namespace v8::internal |
OLD | NEW |