Chromium Code Reviews| 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 void RecordWithStatement() { scope_contains_with_ = true; } | 199 void RecordWithStatement() { scope_contains_with_ = true; } |
| 200 | 200 |
| 201 // Inform the scope that the corresponding code contains an eval call. | 201 // Inform the scope that the corresponding code contains an eval call. |
| 202 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } | 202 void RecordEvalCall() { if (!is_global_scope()) scope_calls_eval_ = true; } |
| 203 | 203 |
| 204 // Enable strict mode for the scope (unless disabled by a global flag). | 204 // Enable strict mode for the scope (unless disabled by a global flag). |
| 205 void EnableStrictMode() { | 205 void EnableStrictMode() { |
| 206 strict_mode_ = FLAG_strict_mode; | 206 strict_mode_ = FLAG_strict_mode; |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Statement position in the source where this scope begins. | |
| 210 int SourceBegStatementPos() const { return source_beg_statement_pos_; } | |
|
Kevin Millikin (Chromium)
2011/10/05 08:43:36
I don't like the name :)
First, it doesn't follow
Steven
2011/10/06 19:09:27
Done.
| |
| 211 void SetSourceBegStatementPos(int statement_pos) { | |
| 212 source_beg_statement_pos_ = statement_pos; | |
| 213 } | |
| 214 | |
| 215 // Statement position in the source where this scope ends. | |
| 216 int SourceEndStatementPos() const { return source_end_statement_pos_; } | |
|
Kevin Millikin (Chromium)
2011/10/05 08:43:36
Likewise:
int end_position() const { return end_p
Steven
2011/10/06 19:09:27
Done.
| |
| 217 void SetSourceEndStatementPos(int statement_pos) { | |
| 218 source_end_statement_pos_ = statement_pos; | |
| 219 } | |
| 220 | |
| 209 // --------------------------------------------------------------------------- | 221 // --------------------------------------------------------------------------- |
| 210 // Predicates. | 222 // Predicates. |
| 211 | 223 |
| 212 // Specific scope types. | 224 // Specific scope types. |
| 213 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } | 225 bool is_eval_scope() const { return type_ == EVAL_SCOPE; } |
| 214 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } | 226 bool is_function_scope() const { return type_ == FUNCTION_SCOPE; } |
| 215 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } | 227 bool is_global_scope() const { return type_ == GLOBAL_SCOPE; } |
| 216 bool is_catch_scope() const { return type_ == CATCH_SCOPE; } | 228 bool is_catch_scope() const { return type_ == CATCH_SCOPE; } |
| 217 bool is_block_scope() const { return type_ == BLOCK_SCOPE; } | 229 bool is_block_scope() const { return type_ == BLOCK_SCOPE; } |
| 218 bool is_with_scope() const { return type_ == WITH_SCOPE; } | 230 bool is_with_scope() const { return type_ == WITH_SCOPE; } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 237 bool inside_with() const { return scope_inside_with_; } | 249 bool inside_with() const { return scope_inside_with_; } |
| 238 // Does this scope contain a with statement. | 250 // Does this scope contain a with statement. |
| 239 bool contains_with() const { return scope_contains_with_; } | 251 bool contains_with() const { return scope_contains_with_; } |
| 240 | 252 |
| 241 // The scope immediately surrounding this scope, or NULL. | 253 // The scope immediately surrounding this scope, or NULL. |
| 242 Scope* outer_scope() const { return outer_scope_; } | 254 Scope* outer_scope() const { return outer_scope_; } |
| 243 | 255 |
| 244 // --------------------------------------------------------------------------- | 256 // --------------------------------------------------------------------------- |
| 245 // Accessors. | 257 // Accessors. |
| 246 | 258 |
| 259 // The type of this scope. | |
| 260 Type type() const { return type_; } | |
| 261 | |
| 247 // The variable corresponding the 'this' value. | 262 // The variable corresponding the 'this' value. |
| 248 Variable* receiver() { return receiver_; } | 263 Variable* receiver() { return receiver_; } |
| 249 | 264 |
| 250 // The variable holding the function literal for named function | 265 // The variable holding the function literal for named function |
| 251 // literals, or NULL. | 266 // literals, or NULL. |
| 252 // Only valid for function scopes. | 267 // Only valid for function scopes. |
| 253 VariableProxy* function() const { | 268 VariableProxy* function() const { |
| 254 ASSERT(is_function_scope()); | 269 ASSERT(is_function_scope()); |
| 255 return function_; | 270 return function_; |
| 256 } | 271 } |
| 257 | 272 |
| 258 // Parameters. The left-most parameter has index 0. | 273 // Parameters. The left-most parameter has index 0. |
| 259 // Only valid for function scopes. | 274 // Only valid for function scopes. |
| 260 Variable* parameter(int index) const { | 275 Variable* parameter(int index) const { |
| 261 ASSERT(is_function_scope()); | 276 ASSERT(is_function_scope()); |
| 262 return params_[index]; | 277 return params_[index]; |
| 263 } | 278 } |
| 264 | 279 |
| 265 int num_parameters() const { return params_.length(); } | 280 int num_parameters() const { return params_.length(); } |
| 266 | 281 |
| 267 // The local variable 'arguments' if we need to allocate it; NULL otherwise. | 282 // The local variable 'arguments' if we need to allocate it; NULL otherwise. |
| 268 Variable* arguments() const { return arguments_; } | 283 Variable* arguments() const { return arguments_; } |
| 269 | 284 |
| 270 // Declarations list. | 285 // Declarations list. |
| 271 ZoneList<Declaration*>* declarations() { return &decls_; } | 286 ZoneList<Declaration*>* declarations() { return &decls_; } |
| 272 | 287 |
| 288 // Inner scope list. | |
| 289 ZoneList<Scope*>* InnerScopes() { return &inner_scopes_; } | |
|
Kevin Millikin (Chromium)
2011/10/05 08:43:36
ZoneList<Scope*>* inner_scopes() { return &inner_s
Steven
2011/10/06 19:09:27
Done.
| |
| 273 | 290 |
| 274 // --------------------------------------------------------------------------- | 291 // --------------------------------------------------------------------------- |
| 275 // Variable allocation. | 292 // Variable allocation. |
| 276 | 293 |
| 277 // Collect all used locals in this scope. | 294 // Collect all used locals in this scope. |
| 278 template<class Allocator> | 295 template<class Allocator> |
| 279 void CollectUsedVariables(List<Variable*, Allocator>* locals); | 296 void CollectUsedVariables(List<Variable*, Allocator>* locals); |
| 280 | 297 |
| 281 // Resolve and fill in the allocation information for all variables | 298 // Resolve and fill in the allocation information for all variables |
| 282 // in this scopes. Must be called *after* all scopes have been | 299 // in this scopes. Must be called *after* all scopes have been |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 // | 397 // |
| 381 // This scope is inside a 'with' of some outer scope. | 398 // This scope is inside a 'with' of some outer scope. |
| 382 bool scope_inside_with_; | 399 bool scope_inside_with_; |
| 383 // This scope contains a 'with' statement. | 400 // This scope contains a 'with' statement. |
| 384 bool scope_contains_with_; | 401 bool scope_contains_with_; |
| 385 // This scope or a nested catch scope or with scope contain an 'eval' call. At | 402 // This scope or a nested catch scope or with scope contain an 'eval' call. At |
| 386 // the 'eval' call site this scope is the declaration scope. | 403 // the 'eval' call site this scope is the declaration scope. |
| 387 bool scope_calls_eval_; | 404 bool scope_calls_eval_; |
| 388 // This scope is a strict mode scope. | 405 // This scope is a strict mode scope. |
| 389 bool strict_mode_; | 406 bool strict_mode_; |
| 407 // Source positions. | |
| 408 int source_beg_statement_pos_; | |
| 409 int source_end_statement_pos_; | |
| 390 | 410 |
| 391 // Computed via PropagateScopeInfo. | 411 // Computed via PropagateScopeInfo. |
| 392 bool outer_scope_calls_non_strict_eval_; | 412 bool outer_scope_calls_non_strict_eval_; |
| 393 bool inner_scope_calls_eval_; | 413 bool inner_scope_calls_eval_; |
| 394 bool force_eager_compilation_; | 414 bool force_eager_compilation_; |
| 395 | 415 |
| 396 // True if it doesn't need scope resolution (e.g., if the scope was | 416 // True if it doesn't need scope resolution (e.g., if the scope was |
| 397 // constructed based on a serialized scope info or a catch context). | 417 // constructed based on a serialized scope info or a catch context). |
| 398 bool already_resolved_; | 418 bool already_resolved_; |
| 399 | 419 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 } | 522 } |
| 503 | 523 |
| 504 void SetDefaults(Type type, | 524 void SetDefaults(Type type, |
| 505 Scope* outer_scope, | 525 Scope* outer_scope, |
| 506 Handle<SerializedScopeInfo> scope_info); | 526 Handle<SerializedScopeInfo> scope_info); |
| 507 }; | 527 }; |
| 508 | 528 |
| 509 } } // namespace v8::internal | 529 } } // namespace v8::internal |
| 510 | 530 |
| 511 #endif // V8_SCOPES_H_ | 531 #endif // V8_SCOPES_H_ |
| OLD | NEW |