OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 // True if the outer context of this scope is always the global context. | 330 // True if the outer context of this scope is always the global context. |
331 bool HasTrivialOuterContext() const; | 331 bool HasTrivialOuterContext() const; |
332 | 332 |
333 // The number of contexts between this and scope; zero if this == scope. | 333 // The number of contexts between this and scope; zero if this == scope. |
334 int ContextChainLength(Scope* scope); | 334 int ContextChainLength(Scope* scope); |
335 | 335 |
336 // Find the first function, global, or eval scope. This is the scope | 336 // Find the first function, global, or eval scope. This is the scope |
337 // where var declarations will be hoisted to in the implementation. | 337 // where var declarations will be hoisted to in the implementation. |
338 Scope* DeclarationScope(); | 338 Scope* DeclarationScope(); |
339 | 339 |
340 Handle<SerializedScopeInfo> GetSerializedScopeInfo(); | 340 Handle<ScopeInfo> GetScopeInfo(); |
341 | 341 |
342 // Get the chain of nested scopes within this scope for the source statement | 342 // Get the chain of nested scopes within this scope for the source statement |
343 // position. The scopes will be added to the list from the outermost scope to | 343 // position. The scopes will be added to the list from the outermost scope to |
344 // the innermost scope. Only nested block, catch or with scopes are tracked | 344 // the innermost scope. Only nested block, catch or with scopes are tracked |
345 // and will be returned, but no inner function scopes. | 345 // and will be returned, but no inner function scopes. |
346 void GetNestedScopeChain(List<Handle<SerializedScopeInfo> >* chain, | 346 void GetNestedScopeChain(List<Handle<ScopeInfo> >* chain, |
347 int statement_position); | 347 int statement_position); |
348 | 348 |
349 // --------------------------------------------------------------------------- | 349 // --------------------------------------------------------------------------- |
350 // Strict mode support. | 350 // Strict mode support. |
351 bool IsDeclared(Handle<String> name) { | 351 bool IsDeclared(Handle<String> name) { |
352 // During formal parameter list parsing the scope only contains | 352 // During formal parameter list parsing the scope only contains |
353 // two variables inserted at initialization: "this" and "arguments". | 353 // two variables inserted at initialization: "this" and "arguments". |
354 // "this" is an invalid parameter name and "arguments" is invalid parameter | 354 // "this" is an invalid parameter name and "arguments" is invalid parameter |
355 // name in strict mode. Therefore looking up with the map which includes | 355 // name in strict mode. Therefore looking up with the map which includes |
356 // "this" and "arguments" in addition to all formal parameters is safe. | 356 // "this" and "arguments" in addition to all formal parameters is safe. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // constructed based on a serialized scope info or a catch context). | 431 // constructed based on a serialized scope info or a catch context). |
432 bool already_resolved_; | 432 bool already_resolved_; |
433 | 433 |
434 // Computed as variables are declared. | 434 // Computed as variables are declared. |
435 int num_var_or_const_; | 435 int num_var_or_const_; |
436 | 436 |
437 // Computed via AllocateVariables; function, block and catch scopes only. | 437 // Computed via AllocateVariables; function, block and catch scopes only. |
438 int num_stack_slots_; | 438 int num_stack_slots_; |
439 int num_heap_slots_; | 439 int num_heap_slots_; |
440 | 440 |
441 // Serialized scopes support. | 441 // Serialized scope info support. |
442 Handle<SerializedScopeInfo> scope_info_; | 442 Handle<ScopeInfo> scope_info_; |
443 bool already_resolved() { return already_resolved_; } | 443 bool already_resolved() { return already_resolved_; } |
444 | 444 |
445 // Create a non-local variable with a given name. | 445 // Create a non-local variable with a given name. |
446 // These variables are looked up dynamically at runtime. | 446 // These variables are looked up dynamically at runtime. |
447 Variable* NonLocal(Handle<String> name, VariableMode mode); | 447 Variable* NonLocal(Handle<String> name, VariableMode mode); |
448 | 448 |
449 // Variable resolution. | 449 // Variable resolution. |
450 // Possible results of a recursive variable lookup telling if and how a | 450 // Possible results of a recursive variable lookup telling if and how a |
451 // variable is bound. These are returned in the output parameter *binding_kind | 451 // variable is bound. These are returned in the output parameter *binding_kind |
452 // of the LookupRecursive function. | 452 // of the LookupRecursive function. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // Variable allocation. | 516 // Variable allocation. |
517 void AllocateStackSlot(Variable* var); | 517 void AllocateStackSlot(Variable* var); |
518 void AllocateHeapSlot(Variable* var); | 518 void AllocateHeapSlot(Variable* var); |
519 void AllocateParameterLocals(); | 519 void AllocateParameterLocals(); |
520 void AllocateNonParameterLocal(Variable* var); | 520 void AllocateNonParameterLocal(Variable* var); |
521 void AllocateNonParameterLocals(); | 521 void AllocateNonParameterLocals(); |
522 void AllocateVariablesRecursively(); | 522 void AllocateVariablesRecursively(); |
523 | 523 |
524 private: | 524 private: |
525 // Construct a scope based on the scope info. | 525 // Construct a scope based on the scope info. |
526 Scope(Scope* inner_scope, | 526 Scope(Scope* inner_scope, ScopeType type, Handle<ScopeInfo> scope_info); |
527 ScopeType type, | |
528 Handle<SerializedScopeInfo> scope_info); | |
529 | 527 |
530 // Construct a catch scope with a binding for the name. | 528 // Construct a catch scope with a binding for the name. |
531 Scope(Scope* inner_scope, Handle<String> catch_variable_name); | 529 Scope(Scope* inner_scope, Handle<String> catch_variable_name); |
532 | 530 |
533 void AddInnerScope(Scope* inner_scope) { | 531 void AddInnerScope(Scope* inner_scope) { |
534 if (inner_scope != NULL) { | 532 if (inner_scope != NULL) { |
535 inner_scopes_.Add(inner_scope); | 533 inner_scopes_.Add(inner_scope); |
536 inner_scope->outer_scope_ = this; | 534 inner_scope->outer_scope_ = this; |
537 } | 535 } |
538 } | 536 } |
539 | 537 |
540 void SetDefaults(ScopeType type, | 538 void SetDefaults(ScopeType type, |
541 Scope* outer_scope, | 539 Scope* outer_scope, |
542 Handle<SerializedScopeInfo> scope_info); | 540 Handle<ScopeInfo> scope_info); |
543 }; | 541 }; |
544 | 542 |
545 } } // namespace v8::internal | 543 } } // namespace v8::internal |
546 | 544 |
547 #endif // V8_SCOPES_H_ | 545 #endif // V8_SCOPES_H_ |
OLD | NEW |