Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: src/runtime/runtime-scopes.cc

Issue 958053003: Removed funky Maybe constructor and made fields private. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/runtime/runtime-utils.h" 10 #include "src/runtime/runtime-utils.h"
(...skipping 28 matching lines...) Expand all
39 global->native_context()->script_context_table()); 39 global->native_context()->script_context_table());
40 ScriptContextTable::LookupResult lookup; 40 ScriptContextTable::LookupResult lookup;
41 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) && 41 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) &&
42 IsLexicalVariableMode(lookup.mode)) { 42 IsLexicalVariableMode(lookup.mode)) {
43 return ThrowRedeclarationError(isolate, name); 43 return ThrowRedeclarationError(isolate, name);
44 } 44 }
45 45
46 // Do the lookup own properties only, see ES5 erratum. 46 // Do the lookup own properties only, see ES5 erratum.
47 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 47 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
48 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 48 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
49 if (!maybe.has_value) return isolate->heap()->exception(); 49 if (!maybe.IsJust()) return isolate->heap()->exception();
50 50
51 if (it.IsFound()) { 51 if (it.IsFound()) {
52 PropertyAttributes old_attributes = maybe.value; 52 PropertyAttributes old_attributes = maybe.FromJust();
53 // The name was declared before; check for conflicting re-declarations. 53 // The name was declared before; check for conflicting re-declarations.
54 if (is_const) return ThrowRedeclarationError(isolate, name); 54 if (is_const) return ThrowRedeclarationError(isolate, name);
55 55
56 // Skip var re-declarations. 56 // Skip var re-declarations.
57 if (is_var) return isolate->heap()->undefined_value(); 57 if (is_var) return isolate->heap()->undefined_value();
58 58
59 DCHECK(is_function); 59 DCHECK(is_function);
60 if ((old_attributes & DONT_DELETE) != 0) { 60 if ((old_attributes & DONT_DELETE) != 0) {
61 // Only allow reconfiguring globals to functions in user code (no 61 // Only allow reconfiguring globals to functions in user code (no
62 // natives, which are marked as read-only). 62 // natives, which are marked as read-only).
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // is the second. 171 // is the second.
172 RUNTIME_ASSERT(args.length() == 2); 172 RUNTIME_ASSERT(args.length() == 2);
173 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 173 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
174 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 174 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
175 175
176 Handle<GlobalObject> global = isolate->global_object(); 176 Handle<GlobalObject> global = isolate->global_object();
177 177
178 // Lookup the property as own on the global object. 178 // Lookup the property as own on the global object.
179 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 179 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
180 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 180 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
181 DCHECK(maybe.has_value); 181 DCHECK(maybe.IsJust());
182 PropertyAttributes old_attributes = maybe.value; 182 PropertyAttributes old_attributes = maybe.FromJust();
183 183
184 PropertyAttributes attr = 184 PropertyAttributes attr =
185 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 185 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
186 // Set the value if the property is either missing, or the property attributes 186 // Set the value if the property is either missing, or the property attributes
187 // allow setting the value without invoking an accessor. 187 // allow setting the value without invoking an accessor.
188 if (it.IsFound()) { 188 if (it.IsFound()) {
189 // Ignore if we can't reconfigure the value. 189 // Ignore if we can't reconfigure the value.
190 if ((old_attributes & DONT_DELETE) != 0) { 190 if ((old_attributes & DONT_DELETE) != 0) {
191 if ((old_attributes & READ_ONLY) != 0 || 191 if ((old_attributes & READ_ONLY) != 0 ||
192 it.state() == LookupIterator::ACCESSOR) { 192 it.state() == LookupIterator::ACCESSOR) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 CHECK(holder->IsJSObject()); 324 CHECK(holder->IsJSObject());
325 } else { 325 } else {
326 // For JSContextExtensionObjects, the initializer can be run multiple times 326 // For JSContextExtensionObjects, the initializer can be run multiple times
327 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the 327 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the
328 // first assignment should go through. For JSGlobalObjects, additionally any 328 // first assignment should go through. For JSGlobalObjects, additionally any
329 // code can run in between that modifies the declared property. 329 // code can run in between that modifies the declared property.
330 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject()); 330 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject());
331 331
332 LookupIterator it(holder, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 332 LookupIterator it(holder, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
333 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 333 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
334 if (!maybe.has_value) return isolate->heap()->exception(); 334 if (!maybe.IsJust()) return isolate->heap()->exception();
335 PropertyAttributes old_attributes = maybe.value; 335 PropertyAttributes old_attributes = maybe.FromJust();
336 336
337 // Ignore if we can't reconfigure the value. 337 // Ignore if we can't reconfigure the value.
338 if ((old_attributes & DONT_DELETE) != 0) { 338 if ((old_attributes & DONT_DELETE) != 0) {
339 if ((old_attributes & READ_ONLY) != 0 || 339 if ((old_attributes & READ_ONLY) != 0 ||
340 it.state() == LookupIterator::ACCESSOR) { 340 it.state() == LookupIterator::ACCESSOR) {
341 return *value; 341 return *value;
342 } 342 }
343 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY); 343 attr = static_cast<PropertyAttributes>(old_attributes | READ_ONLY);
344 } 344 }
345 } 345 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 if (ScriptContextTable::Lookup(script_context, name, &lookup)) { 589 if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
590 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) { 590 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) {
591 return ThrowRedeclarationError(isolate, name); 591 return ThrowRedeclarationError(isolate, name);
592 } 592 }
593 } 593 }
594 594
595 if (IsLexicalVariableMode(mode)) { 595 if (IsLexicalVariableMode(mode)) {
596 LookupIterator it(global_object, name, 596 LookupIterator it(global_object, name,
597 LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 597 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
598 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 598 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
599 if (!maybe.has_value) return isolate->heap()->exception(); 599 if (!maybe.IsJust()) return isolate->heap()->exception();
600 if ((maybe.value & DONT_DELETE) != 0) { 600 if ((maybe.FromJust() & DONT_DELETE) != 0) {
601 return ThrowRedeclarationError(isolate, name); 601 return ThrowRedeclarationError(isolate, name);
602 } 602 }
603 603
604 GlobalObject::InvalidatePropertyCell(global_object, name); 604 GlobalObject::InvalidatePropertyCell(global_object, name);
605 } 605 }
606 } 606 }
607 return isolate->heap()->undefined_value(); 607 return isolate->heap()->undefined_value();
608 } 608 }
609 609
610 610
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 return Smi::FromInt(frame->GetArgumentsLength()); 1114 return Smi::FromInt(frame->GetArgumentsLength());
1115 } 1115 }
1116 1116
1117 1117
1118 RUNTIME_FUNCTION(RuntimeReference_Arguments) { 1118 RUNTIME_FUNCTION(RuntimeReference_Arguments) {
1119 SealHandleScope shs(isolate); 1119 SealHandleScope shs(isolate);
1120 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate); 1120 return __RT_impl_Runtime_GetArgumentsProperty(args, isolate);
1121 } 1121 }
1122 } 1122 }
1123 } // namespace v8::internal 1123 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698