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

Side by Side Diff: src/scopes.h

Issue 894683003: Introduce LanguageMode, drop StrictMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased (w/ conflicts) Created 5 years, 10 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/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 // 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; } 219 void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
220 220
221 // Inform the scope that the corresponding code invokes "super" constructor. 221 // Inform the scope that the corresponding code invokes "super" constructor.
222 void RecordSuperConstructorCallUsage() { 222 void RecordSuperConstructorCallUsage() {
223 scope_uses_super_constructor_call_ = true; 223 scope_uses_super_constructor_call_ = true;
224 } 224 }
225 225
226 // Inform the scope that the corresponding code uses "this". 226 // Inform the scope that the corresponding code uses "this".
227 void RecordThisUsage() { scope_uses_this_ = true; } 227 void RecordThisUsage() { scope_uses_this_ = true; }
228 228
229 // Set the strict mode flag (unless disabled by a global flag). 229 // Set the language mode flag (unless disabled by a global flag).
230 void SetStrictMode(StrictMode strict_mode) { strict_mode_ = strict_mode; } 230 void SetLanguageMode(LanguageMode language_mode) {
231 language_mode_ = language_mode;
232 }
231 233
232 // Set the ASM module flag. 234 // Set the ASM module flag.
233 void SetAsmModule() { asm_module_ = true; } 235 void SetAsmModule() { asm_module_ = true; }
234 236
235 // Position in the source where this scope begins and ends. 237 // Position in the source where this scope begins and ends.
236 // 238 //
237 // * For the scope of a with statement 239 // * For the scope of a with statement
238 // with (obj) stmt 240 // with (obj) stmt
239 // start position: start position of first token of 'stmt' 241 // start position: start position of first token of 'stmt'
240 // end position: end position of last token of 'stmt' 242 // end position: end position of last token of 'stmt'
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 bool is_script_scope() const { return scope_type_ == SCRIPT_SCOPE; } 286 bool is_script_scope() const { return scope_type_ == SCRIPT_SCOPE; }
285 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; } 287 bool is_catch_scope() const { return scope_type_ == CATCH_SCOPE; }
286 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; } 288 bool is_block_scope() const { return scope_type_ == BLOCK_SCOPE; }
287 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; } 289 bool is_with_scope() const { return scope_type_ == WITH_SCOPE; }
288 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; } 290 bool is_arrow_scope() const { return scope_type_ == ARROW_SCOPE; }
289 bool is_declaration_scope() const { 291 bool is_declaration_scope() const {
290 return is_eval_scope() || is_function_scope() || 292 return is_eval_scope() || is_function_scope() ||
291 is_module_scope() || is_script_scope(); 293 is_module_scope() || is_script_scope();
292 } 294 }
293 bool is_strict_eval_scope() const { 295 bool is_strict_eval_scope() const {
294 return is_eval_scope() && strict_mode_ == STRICT; 296 return is_eval_scope() && is_strict(language_mode_);
295 } 297 }
296 298
297 // Information about which scopes calls eval. 299 // Information about which scopes calls eval.
298 bool calls_eval() const { return scope_calls_eval_; } 300 bool calls_eval() const { return scope_calls_eval_; }
299 bool calls_sloppy_eval() { 301 bool calls_sloppy_eval() {
300 return scope_calls_eval_ && strict_mode_ == SLOPPY; 302 return scope_calls_eval_ && is_sloppy(language_mode_);
301 } 303 }
302 bool outer_scope_calls_sloppy_eval() const { 304 bool outer_scope_calls_sloppy_eval() const {
303 return outer_scope_calls_sloppy_eval_; 305 return outer_scope_calls_sloppy_eval_;
304 } 306 }
305 bool asm_module() const { return asm_module_; } 307 bool asm_module() const { return asm_module_; }
306 bool asm_function() const { return asm_function_; } 308 bool asm_function() const { return asm_function_; }
307 309
308 // Is this scope inside a with statement. 310 // Is this scope inside a with statement.
309 bool inside_with() const { return scope_inside_with_; } 311 bool inside_with() const { return scope_inside_with_; }
310 // Does this scope contain a with statement. 312 // Does this scope contain a with statement.
(...skipping 22 matching lines...) Expand all
333 // Does any inner scope access "this". 335 // Does any inner scope access "this".
334 bool inner_uses_this() const { return inner_scope_uses_this_; } 336 bool inner_uses_this() const { return inner_scope_uses_this_; }
335 337
336 // --------------------------------------------------------------------------- 338 // ---------------------------------------------------------------------------
337 // Accessors. 339 // Accessors.
338 340
339 // The type of this scope. 341 // The type of this scope.
340 ScopeType scope_type() const { return scope_type_; } 342 ScopeType scope_type() const { return scope_type_; }
341 343
342 // The language mode of this scope. 344 // The language mode of this scope.
343 StrictMode strict_mode() const { return strict_mode_; } 345 LanguageMode language_mode() const { return language_mode_; }
344 346
345 // The variable corresponding the 'this' value. 347 // The variable corresponding the 'this' value.
346 Variable* receiver() { return receiver_; } 348 Variable* receiver() { return receiver_; }
347 349
348 // The variable holding the function literal for named function 350 // The variable holding the function literal for named function
349 // literals, or NULL. Only valid for function scopes. 351 // literals, or NULL. Only valid for function scopes.
350 VariableDeclaration* function() const { 352 VariableDeclaration* function() const {
351 DCHECK(is_function_scope()); 353 DCHECK(is_function_scope());
352 return function_; 354 return function_;
353 } 355 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 // This scope uses "super" property ('super.foo'). 542 // This scope uses "super" property ('super.foo').
541 bool scope_uses_super_property_; 543 bool scope_uses_super_property_;
542 // This scope uses "super" constructor ('super(..)'). 544 // This scope uses "super" constructor ('super(..)').
543 bool scope_uses_super_constructor_call_; 545 bool scope_uses_super_constructor_call_;
544 // This scope uses "this". 546 // This scope uses "this".
545 bool scope_uses_this_; 547 bool scope_uses_this_;
546 // This scope contains an "use asm" annotation. 548 // This scope contains an "use asm" annotation.
547 bool asm_module_; 549 bool asm_module_;
548 // This scope's outer context is an asm module. 550 // This scope's outer context is an asm module.
549 bool asm_function_; 551 bool asm_function_;
550 // The strict mode of this scope. 552 // The language mode of this scope.
551 StrictMode strict_mode_; 553 LanguageMode language_mode_;
552 // Source positions. 554 // Source positions.
553 int start_position_; 555 int start_position_;
554 int end_position_; 556 int end_position_;
555 557
556 // Computed via PropagateScopeInfo. 558 // Computed via PropagateScopeInfo.
557 bool outer_scope_calls_sloppy_eval_; 559 bool outer_scope_calls_sloppy_eval_;
558 bool inner_scope_calls_eval_; 560 bool inner_scope_calls_eval_;
559 bool inner_scope_uses_arguments_; 561 bool inner_scope_uses_arguments_;
560 bool inner_scope_uses_super_property_; 562 bool inner_scope_uses_super_property_;
561 bool inner_scope_uses_super_constructor_call_; 563 bool inner_scope_uses_super_constructor_call_;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 Scope* outer_scope, 702 Scope* outer_scope,
701 Handle<ScopeInfo> scope_info); 703 Handle<ScopeInfo> scope_info);
702 704
703 AstValueFactory* ast_value_factory_; 705 AstValueFactory* ast_value_factory_;
704 Zone* zone_; 706 Zone* zone_;
705 }; 707 };
706 708
707 } } // namespace v8::internal 709 } } // namespace v8::internal
708 710
709 #endif // V8_SCOPES_H_ 711 #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