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

Side by Side Diff: src/contexts.h

Issue 1292753007: [es6] Parameter scopes for sloppy eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
OLDNEW
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_CONTEXTS_H_ 5 #ifndef V8_CONTEXTS_H_
6 #define V8_CONTEXTS_H_ 6 #define V8_CONTEXTS_H_
7 7
8 #include "src/heap/heap.h" 8 #include "src/heap/heap.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 10
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // function contexts, and non-NULL for 'with' contexts. 287 // function contexts, and non-NULL for 'with' contexts.
288 // Used to implement the 'with' statement. 288 // Used to implement the 'with' statement.
289 // 289 //
290 // [ extension ] A pointer to an extension JSObject, or NULL. Used to 290 // [ extension ] A pointer to an extension JSObject, or NULL. Used to
291 // implement 'with' statements and dynamic declarations 291 // implement 'with' statements and dynamic declarations
292 // (through 'eval'). The object in a 'with' statement is 292 // (through 'eval'). The object in a 'with' statement is
293 // stored in the extension slot of a 'with' context. 293 // stored in the extension slot of a 'with' context.
294 // Dynamically declared variables/functions are also added 294 // Dynamically declared variables/functions are also added
295 // to lazily allocated extension object. Context::Lookup 295 // to lazily allocated extension object. Context::Lookup
296 // searches the extension object for properties. 296 // searches the extension object for properties.
297 // For global and block contexts, contains the respective 297 // For script and block contexts, contains the respective
298 // ScopeInfo. 298 // ScopeInfo. For block contexts representing sloppy declaration
299 // block scopes, it may also be a struct being a
300 // SloppyBlockWithEvalContextExtension, pairing the ScopeInfo
301 // with an extension object.
299 // For module contexts, points back to the respective JSModule. 302 // For module contexts, points back to the respective JSModule.
300 // 303 //
301 // [ global_object ] A pointer to the global object. Provided for quick 304 // [ global_object ] A pointer to the global object. Provided for quick
302 // access to the global object from inside the code (since 305 // access to the global object from inside the code (since
303 // we always have a context pointer). 306 // we always have a context pointer).
304 // 307 //
305 // In addition, function contexts may have statically allocated context slots 308 // In addition, function contexts may have statically allocated context slots
306 // to store local variables/functions that are accessed from inner functions 309 // to store local variables/functions that are accessed from inner functions
307 // (via static context addresses) or through 'eval' (dynamic context lookups). 310 // (via static context addresses) or through 'eval' (dynamic context lookups).
308 // The native context contains additional slots for fast access to native 311 // The native context contains additional slots for fast access to native
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 JSFunction* closure() { return JSFunction::cast(get(CLOSURE_INDEX)); } 361 JSFunction* closure() { return JSFunction::cast(get(CLOSURE_INDEX)); }
359 void set_closure(JSFunction* closure) { set(CLOSURE_INDEX, closure); } 362 void set_closure(JSFunction* closure) { set(CLOSURE_INDEX, closure); }
360 363
361 Context* previous() { 364 Context* previous() {
362 Object* result = unchecked_previous(); 365 Object* result = unchecked_previous();
363 DCHECK(IsBootstrappingOrValidParentContext(result, this)); 366 DCHECK(IsBootstrappingOrValidParentContext(result, this));
364 return reinterpret_cast<Context*>(result); 367 return reinterpret_cast<Context*>(result);
365 } 368 }
366 void set_previous(Context* context) { set(PREVIOUS_INDEX, context); } 369 void set_previous(Context* context) { set(PREVIOUS_INDEX, context); }
367 370
368 bool has_extension() { return extension() != NULL; } 371 bool has_extension() { return extension() != nullptr; }
369 Object* extension() { return get(EXTENSION_INDEX); } 372 Object* extension() { return get(EXTENSION_INDEX); }
370 void set_extension(Object* object) { set(EXTENSION_INDEX, object); } 373 void set_extension(Object* object) { set(EXTENSION_INDEX, object); }
374 JSObject* extension_object();
375 JSReceiver* extension_receiver();
376 ScopeInfo* scope_info();
377 String* catch_name();
371 378
372 JSModule* module() { return JSModule::cast(get(EXTENSION_INDEX)); } 379 JSModule* module() { return JSModule::cast(get(EXTENSION_INDEX)); }
373 void set_module(JSModule* module) { set(EXTENSION_INDEX, module); } 380 void set_module(JSModule* module) { set(EXTENSION_INDEX, module); }
374 381
375 // Get the context where var declarations will be hoisted to, which 382 // Get the context where var declarations will be hoisted to, which
376 // may be the context itself. 383 // may be the context itself.
377 Context* declaration_context(); 384 Context* declaration_context();
385 bool is_declaration_context();
378 386
379 GlobalObject* global_object() { 387 GlobalObject* global_object() {
380 Object* result = get(GLOBAL_OBJECT_INDEX); 388 Object* result = get(GLOBAL_OBJECT_INDEX);
381 DCHECK(IsBootstrappingOrGlobalObject(this->GetIsolate(), result)); 389 DCHECK(IsBootstrappingOrGlobalObject(this->GetIsolate(), result));
382 return reinterpret_cast<GlobalObject*>(result); 390 return reinterpret_cast<GlobalObject*>(result);
383 } 391 }
384 void set_global_object(GlobalObject* object) { 392 void set_global_object(GlobalObject* object) {
385 set(GLOBAL_OBJECT_INDEX, object); 393 set(GLOBAL_OBJECT_INDEX, object);
386 } 394 }
387 395
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object); 552 static bool IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object);
545 #endif 553 #endif
546 554
547 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize); 555 STATIC_ASSERT(kHeaderSize == Internals::kContextHeaderSize);
548 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex); 556 STATIC_ASSERT(EMBEDDER_DATA_INDEX == Internals::kContextEmbedderDataIndex);
549 }; 557 };
550 558
551 } } // namespace v8::internal 559 } } // namespace v8::internal
552 560
553 #endif // V8_CONTEXTS_H_ 561 #endif // V8_CONTEXTS_H_
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/contexts.cc » ('j') | src/contexts.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698