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

Side by Side Diff: src/scopes.h

Issue 181543002: Eliminate extended mode, and other modes clean-up (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // --------------------------------------------------------------------------- 227 // ---------------------------------------------------------------------------
228 // Scope-specific info. 228 // Scope-specific info.
229 229
230 // Inform the scope that the corresponding code contains a with statement. 230 // Inform the scope that the corresponding code contains a with statement.
231 void RecordWithStatement() { scope_contains_with_ = true; } 231 void RecordWithStatement() { scope_contains_with_ = true; }
232 232
233 // Inform the scope that the corresponding code contains an eval call. 233 // Inform the scope that the corresponding code contains an eval call.
234 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } 234 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; }
235 235
236 // Set the strict mode flag (unless disabled by a global flag). 236 // Set the strict mode flag (unless disabled by a global flag).
237 void SetLanguageMode(LanguageMode language_mode) { 237 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; }
238 language_mode_ = language_mode;
239 }
240 238
241 // Position in the source where this scope begins and ends. 239 // Position in the source where this scope begins and ends.
242 // 240 //
243 // * For the scope of a with statement 241 // * For the scope of a with statement
244 // with (obj) stmt 242 // with (obj) stmt
245 // start position: start position of first token of 'stmt' 243 // start position: start position of first token of 'stmt'
246 // end position: end position of last token of 'stmt' 244 // end position: end position of last token of 'stmt'
247 // * For the scope of a block 245 // * For the scope of a block
248 // { stmts } 246 // { stmts }
249 // start position: start position of '{' 247 // start position: start position of '{'
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 bool is_function_scope() const { return scope_type_ == FUNCTION_SCOPE; } 284 bool is_function_scope() const { return scope_type_ == FUNCTION_SCOPE; }
287 bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; } 285 bool is_module_scope() const { return scope_type_ == MODULE_SCOPE; }
288 bool is_global_scope() const { return scope_type_ == GLOBAL_SCOPE; } 286 bool is_global_scope() const { return scope_type_ == GLOBAL_SCOPE; }
289 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } 287 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
290 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } 288 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
291 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } 289 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
292 bool is_declaration_scope() const { 290 bool is_declaration_scope() const {
293 return is_eval_scope() || is_function_scope() || 291 return is_eval_scope() || is_function_scope() ||
294 is_module_scope() || is_global_scope(); 292 is_module_scope() || is_global_scope();
295 } 293 }
296 bool is_sloppy_mode() const { 294 bool is_strict_eval_scope() const {
297 return language_mode() == SLOPPY_MODE; 295 return is_eval_scope() && strict_mode_ == STRICT;
298 }
299 bool is_extended_mode() const {
300 return language_mode() == EXTENDED_MODE;
301 }
302 bool is_strict_or_extended_eval_scope() const {
303 return is_eval_scope() && !is_sloppy_mode();
304 } 296 }
305 297
306 // Information about which scopes calls eval. 298 // Information about which scopes calls eval.
307 bool calls_eval() const { return scope_calls_eval_; } 299 bool calls_eval() const { return scope_calls_eval_; }
308 bool calls_sloppy_eval() { return scope_calls_eval_ && is_sloppy_mode(); } 300 bool calls_sloppy_eval() {
301 return scope_calls_eval_ && strict_mode_ == SLOPPY;
302 }
309 bool outer_scope_calls_sloppy_eval() const { 303 bool outer_scope_calls_sloppy_eval() const {
310 return outer_scope_calls_sloppy_eval_; 304 return outer_scope_calls_sloppy_eval_;
311 } 305 }
312 306
313 // Is this scope inside a with statement. 307 // Is this scope inside a with statement.
314 bool inside_with() const { return scope_inside_with_; } 308 bool inside_with() const { return scope_inside_with_; }
315 // Does this scope contain a with statement. 309 // Does this scope contain a with statement.
316 bool contains_with() const { return scope_contains_with_; } 310 bool contains_with() const { return scope_contains_with_; }
317 311
318 // --------------------------------------------------------------------------- 312 // ---------------------------------------------------------------------------
319 // Accessors. 313 // Accessors.
320 314
321 // The type of this scope. 315 // The type of this scope.
322 ScopeType scope_type() const { return scope_type_; } 316 ScopeType scope_type() const { return scope_type_; }
323 317
324 // The language mode of this scope. 318 // The language mode of this scope.
325 LanguageMode language_mode() const { return language_mode_; } 319 StrictMode strict_mode() const { return strict_mode_; }
326 320
327 // The variable corresponding the 'this' value. 321 // The variable corresponding the 'this' value.
328 Variable* receiver() { return receiver_; } 322 Variable* receiver() { return receiver_; }
329 323
330 // The variable holding the function literal for named function 324 // The variable holding the function literal for named function
331 // literals, or NULL. Only valid for function scopes. 325 // literals, or NULL. Only valid for function scopes.
332 VariableDeclaration* function() const { 326 VariableDeclaration* function() const {
333 ASSERT(is_function_scope()); 327 ASSERT(is_function_scope());
334 return function_; 328 return function_;
335 } 329 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 478
485 // Scope-specific information computed during parsing. 479 // Scope-specific information computed during parsing.
486 // 480 //
487 // This scope is inside a 'with' of some outer scope. 481 // This scope is inside a 'with' of some outer scope.
488 bool scope_inside_with_; 482 bool scope_inside_with_;
489 // This scope contains a 'with' statement. 483 // This scope contains a 'with' statement.
490 bool scope_contains_with_; 484 bool scope_contains_with_;
491 // This scope or a nested catch scope or with scope contain an 'eval' call. At 485 // This scope or a nested catch scope or with scope contain an 'eval' call. At
492 // the 'eval' call site this scope is the declaration scope. 486 // the 'eval' call site this scope is the declaration scope.
493 bool scope_calls_eval_; 487 bool scope_calls_eval_;
494 // The language mode of this scope. 488 // The strict mode of this scope.
495 LanguageMode language_mode_; 489 StrictMode strict_mode_;
496 // Source positions. 490 // Source positions.
497 int start_position_; 491 int start_position_;
498 int end_position_; 492 int end_position_;
499 493
500 // Computed via PropagateScopeInfo. 494 // Computed via PropagateScopeInfo.
501 bool outer_scope_calls_sloppy_eval_; 495 bool outer_scope_calls_sloppy_eval_;
502 bool inner_scope_calls_eval_; 496 bool inner_scope_calls_eval_;
503 bool force_eager_compilation_; 497 bool force_eager_compilation_;
504 bool force_context_allocation_; 498 bool force_context_allocation_;
505 499
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 void SetDefaults(ScopeType type, 630 void SetDefaults(ScopeType type,
637 Scope* outer_scope, 631 Scope* outer_scope,
638 Handle<ScopeInfo> scope_info); 632 Handle<ScopeInfo> scope_info);
639 633
640 Zone* zone_; 634 Zone* zone_;
641 }; 635 };
642 636
643 } } // namespace v8::internal 637 } } // namespace v8::internal
644 638
645 #endif // V8_SCOPES_H_ 639 #endif // V8_SCOPES_H_
OLDNEW
« no previous file with comments | « src/scopeinfo.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698