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 Handle<Object> args[2] = {key, object}; | 73 THROW_NEW_ERROR( |
74 THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_load", | 74 isolate, |
75 HandleVector(args, 2)), | 75 NewTypeError(MessageTemplate::kNonObjectPropertyLoad, key, object), |
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 Handle<Object> args[2] = {key, object}; | 105 THROW_NEW_ERROR( |
106 THROW_NEW_ERROR(isolate, NewTypeError("non_object_property_store", | 106 isolate, |
107 HandleVector(args, 2)), | 107 NewTypeError(MessageTemplate::kNonObjectPropertyStore, key, object), |
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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 isolate, result, | 1412 isolate, result, |
1413 Runtime::DefineObjectProperty(js_object, name, obj_value, attrs)); | 1413 Runtime::DefineObjectProperty(js_object, name, obj_value, attrs)); |
1414 return *result; | 1414 return *result; |
1415 } | 1415 } |
1416 | 1416 |
1417 | 1417 |
1418 // Return property without being observable by accessors or interceptors. | 1418 // Return property without being observable by accessors or interceptors. |
1419 RUNTIME_FUNCTION(Runtime_GetDataProperty) { | 1419 RUNTIME_FUNCTION(Runtime_GetDataProperty) { |
1420 HandleScope scope(isolate); | 1420 HandleScope scope(isolate); |
1421 DCHECK(args.length() == 2); | 1421 DCHECK(args.length() == 2); |
1422 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 1422 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
1423 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 1423 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
1424 return *JSObject::GetDataProperty(object, key); | 1424 return *JSReceiver::GetDataProperty(object, key); |
1425 } | 1425 } |
1426 | 1426 |
1427 | 1427 |
1428 RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { | 1428 RUNTIME_FUNCTION(Runtime_HasFastPackedElements) { |
1429 SealHandleScope shs(isolate); | 1429 SealHandleScope shs(isolate); |
1430 DCHECK(args.length() == 1); | 1430 DCHECK(args.length() == 1); |
1431 CONVERT_ARG_CHECKED(HeapObject, obj, 0); | 1431 CONVERT_ARG_CHECKED(HeapObject, obj, 0); |
1432 return isolate->heap()->ToBoolean( | 1432 return isolate->heap()->ToBoolean( |
1433 IsFastPackedElementsKind(obj->map()->elements_kind())); | 1433 IsFastPackedElementsKind(obj->map()->elements_kind())); |
1434 } | 1434 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1552 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); | 1552 CONVERT_PROPERTY_ATTRIBUTES_CHECKED(attrs, 3); |
1553 | 1553 |
1554 RETURN_FAILURE_ON_EXCEPTION( | 1554 RETURN_FAILURE_ON_EXCEPTION( |
1555 isolate, | 1555 isolate, |
1556 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), | 1556 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(), |
1557 setter, attrs)); | 1557 setter, attrs)); |
1558 return isolate->heap()->undefined_value(); | 1558 return isolate->heap()->undefined_value(); |
1559 } | 1559 } |
1560 } | 1560 } |
1561 } // namespace v8::internal | 1561 } // namespace v8::internal |
OLD | NEW |