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

Side by Side Diff: src/scopes.h

Issue 422923004: Track usage of "this" and "arguments" in Scope (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase and fix parser instantiation after r23600 Created 6 years, 3 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 | Annotate | Revision Log
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_SCOPES_H_ 5 #ifndef V8_SCOPES_H_
6 #define V8_SCOPES_H_ 6 #define V8_SCOPES_H_
7 7
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/zone.h" 9 #include "src/zone.h"
10 10
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 204
205 // --------------------------------------------------------------------------- 205 // ---------------------------------------------------------------------------
206 // Scope-specific info. 206 // Scope-specific info.
207 207
208 // Inform the scope that the corresponding code contains a with statement. 208 // Inform the scope that the corresponding code contains a with statement.
209 void RecordWithStatement() { scope_contains_with_ = true; } 209 void RecordWithStatement() { scope_contains_with_ = true; }
210 210
211 // Inform the scope that the corresponding code contains an eval call. 211 // Inform the scope that the corresponding code contains an eval call.
212 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } 212 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; }
213 213
214 // Inform the scope that the corresponding code uses "this".
215 void RecordThisUsage() { scope_uses_this_ = true; }
216
217 // Inform the scope that the corresponding code uses "arguments".
218 void RecordArgumentsUsage() { scope_uses_arguments_ = true; }
219
214 // Set the strict mode flag (unless disabled by a global flag). 220 // Set the strict mode flag (unless disabled by a global flag).
215 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } 221 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; }
216 222
217 // Position in the source where this scope begins and ends. 223 // Position in the source where this scope begins and ends.
218 // 224 //
219 // * For the scope of a with statement 225 // * For the scope of a with statement
220 // with (obj) stmt 226 // with (obj) stmt
221 // start position: start position of first token of 'stmt' 227 // start position: start position of first token of 'stmt'
222 // end position: end position of last token of 'stmt' 228 // end position: end position of last token of 'stmt'
223 // * For the scope of a block 229 // * For the scope of a block
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 286 }
281 bool outer_scope_calls_sloppy_eval() const { 287 bool outer_scope_calls_sloppy_eval() const {
282 return outer_scope_calls_sloppy_eval_; 288 return outer_scope_calls_sloppy_eval_;
283 } 289 }
284 290
285 // Is this scope inside a with statement. 291 // Is this scope inside a with statement.
286 bool inside_with() const { return scope_inside_with_; } 292 bool inside_with() const { return scope_inside_with_; }
287 // Does this scope contain a with statement. 293 // Does this scope contain a with statement.
288 bool contains_with() const { return scope_contains_with_; } 294 bool contains_with() const { return scope_contains_with_; }
289 295
296 // Does this scope access "this".
297 bool uses_this() const { return scope_uses_this_; }
298 // Does any inner scope access "this".
299 bool inner_uses_this() const { return inner_scope_uses_this_; }
300 // Does this scope access "arguments".
301 bool uses_arguments() const { return scope_uses_arguments_; }
302 // Does any inner scope access "arguments".
303 bool inner_uses_arguments() const { return inner_scope_uses_arguments_; }
304
290 // --------------------------------------------------------------------------- 305 // ---------------------------------------------------------------------------
291 // Accessors. 306 // Accessors.
292 307
293 // The type of this scope. 308 // The type of this scope.
294 ScopeType scope_type() const { return scope_type_; } 309 ScopeType scope_type() const { return scope_type_; }
295 310
296 // The language mode of this scope. 311 // The language mode of this scope.
297 StrictMode strict_mode() const { return strict_mode_; } 312 StrictMode strict_mode() const { return strict_mode_; }
298 313
299 // The variable corresponding the 'this' value. 314 // The variable corresponding the 'this' value.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 471
457 // Scope-specific information computed during parsing. 472 // Scope-specific information computed during parsing.
458 // 473 //
459 // This scope is inside a 'with' of some outer scope. 474 // This scope is inside a 'with' of some outer scope.
460 bool scope_inside_with_; 475 bool scope_inside_with_;
461 // This scope contains a 'with' statement. 476 // This scope contains a 'with' statement.
462 bool scope_contains_with_; 477 bool scope_contains_with_;
463 // This scope or a nested catch scope or with scope contain an 'eval' call. At 478 // This scope or a nested catch scope or with scope contain an 'eval' call. At
464 // the 'eval' call site this scope is the declaration scope. 479 // the 'eval' call site this scope is the declaration scope.
465 bool scope_calls_eval_; 480 bool scope_calls_eval_;
481 // This scope uses "this".
482 bool scope_uses_this_;
483 // This scope uses "arguments".
484 bool scope_uses_arguments_;
466 // The strict mode of this scope. 485 // The strict mode of this scope.
467 StrictMode strict_mode_; 486 StrictMode strict_mode_;
468 // Source positions. 487 // Source positions.
469 int start_position_; 488 int start_position_;
470 int end_position_; 489 int end_position_;
471 490
472 // Computed via PropagateScopeInfo. 491 // Computed via PropagateScopeInfo.
473 bool outer_scope_calls_sloppy_eval_; 492 bool outer_scope_calls_sloppy_eval_;
474 bool inner_scope_calls_eval_; 493 bool inner_scope_calls_eval_;
494 bool inner_scope_uses_this_;
495 bool inner_scope_uses_arguments_;
475 bool force_eager_compilation_; 496 bool force_eager_compilation_;
476 bool force_context_allocation_; 497 bool force_context_allocation_;
477 498
478 // True if it doesn't need scope resolution (e.g., if the scope was 499 // True if it doesn't need scope resolution (e.g., if the scope was
479 // constructed based on a serialized scope info or a catch context). 500 // constructed based on a serialized scope info or a catch context).
480 bool already_resolved_; 501 bool already_resolved_;
481 502
482 // Computed as variables are declared. 503 // Computed as variables are declared.
483 int num_var_or_const_; 504 int num_var_or_const_;
484 505
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 Scope* outer_scope, 632 Scope* outer_scope,
612 Handle<ScopeInfo> scope_info); 633 Handle<ScopeInfo> scope_info);
613 634
614 AstValueFactory* ast_value_factory_; 635 AstValueFactory* ast_value_factory_;
615 Zone* zone_; 636 Zone* zone_;
616 }; 637 };
617 638
618 } } // namespace v8::internal 639 } } // namespace v8::internal
619 640
620 #endif // V8_SCOPES_H_ 641 #endif // V8_SCOPES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698