OLD | NEW |
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_PARSING_PARSER_BASE_H | 5 #ifndef V8_PARSING_PARSER_BASE_H |
6 #define V8_PARSING_PARSER_BASE_H | 6 #define V8_PARSING_PARSER_BASE_H |
7 | 7 |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 return next_materialized_literal_index_; | 400 return next_materialized_literal_index_; |
401 } | 401 } |
402 | 402 |
403 void SkipMaterializedLiterals(int count) { | 403 void SkipMaterializedLiterals(int count) { |
404 next_materialized_literal_index_ += count; | 404 next_materialized_literal_index_ += count; |
405 } | 405 } |
406 | 406 |
407 void AddProperty() { expected_property_count_++; } | 407 void AddProperty() { expected_property_count_++; } |
408 int expected_property_count() { return expected_property_count_; } | 408 int expected_property_count() { return expected_property_count_; } |
409 | 409 |
410 bool is_generator() const { return IsGeneratorFunction(kind()); } | |
411 bool is_async_function() const { return IsAsyncFunction(kind()); } | |
412 bool is_resumable() const { return is_generator() || is_async_function(); } | |
413 | |
414 FunctionKind kind() const { return scope()->function_kind(); } | 410 FunctionKind kind() const { return scope()->function_kind(); } |
415 FunctionState* outer() const { return outer_function_state_; } | 411 FunctionState* outer() const { return outer_function_state_; } |
416 | 412 |
417 void set_generator_object_variable(typename Types::Variable* variable) { | 413 void set_generator_object_variable(typename Types::Variable* variable) { |
418 DCHECK(variable != NULL); | 414 DCHECK(variable != NULL); |
419 DCHECK(is_resumable()); | 415 DCHECK(IsResumableFunction(kind())); |
420 generator_object_variable_ = variable; | 416 generator_object_variable_ = variable; |
421 } | 417 } |
422 typename Types::Variable* generator_object_variable() const { | 418 typename Types::Variable* generator_object_variable() const { |
423 return generator_object_variable_; | 419 return generator_object_variable_; |
424 } | 420 } |
425 | 421 |
426 void set_promise_variable(typename Types::Variable* variable) { | 422 void set_promise_variable(typename Types::Variable* variable) { |
427 DCHECK(variable != NULL); | 423 DCHECK(variable != NULL); |
428 DCHECK(is_async_function()); | 424 DCHECK(IsAsyncFunction(kind())); |
429 promise_variable_ = variable; | 425 promise_variable_ = variable; |
430 } | 426 } |
431 typename Types::Variable* promise_variable() const { | 427 typename Types::Variable* promise_variable() const { |
432 return promise_variable_; | 428 return promise_variable_; |
433 } | 429 } |
434 | 430 |
435 const ZoneList<DestructuringAssignment>& | 431 const ZoneList<DestructuringAssignment>& |
436 destructuring_assignments_to_rewrite() const { | 432 destructuring_assignments_to_rewrite() const { |
437 return destructuring_assignments_to_rewrite_; | 433 return destructuring_assignments_to_rewrite_; |
438 } | 434 } |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 typename Types::Factory* factory() { return &ast_node_factory_; } | 929 typename Types::Factory* factory() { return &ast_node_factory_; } |
934 | 930 |
935 DeclarationScope* GetReceiverScope() const { | 931 DeclarationScope* GetReceiverScope() const { |
936 return scope()->GetReceiverScope(); | 932 return scope()->GetReceiverScope(); |
937 } | 933 } |
938 LanguageMode language_mode() { return scope()->language_mode(); } | 934 LanguageMode language_mode() { return scope()->language_mode(); } |
939 void RaiseLanguageMode(LanguageMode mode) { | 935 void RaiseLanguageMode(LanguageMode mode) { |
940 LanguageMode old = scope()->language_mode(); | 936 LanguageMode old = scope()->language_mode(); |
941 impl()->SetLanguageMode(scope(), old > mode ? old : mode); | 937 impl()->SetLanguageMode(scope(), old > mode ? old : mode); |
942 } | 938 } |
943 bool is_generator() const { return function_state_->is_generator(); } | 939 bool is_generator() const { |
| 940 return IsGeneratorFunction(function_state_->kind()); |
| 941 } |
944 bool is_async_function() const { | 942 bool is_async_function() const { |
945 return function_state_->is_async_function(); | 943 return IsAsyncFunction(function_state_->kind()); |
946 } | 944 } |
947 bool is_resumable() const { return function_state_->is_resumable(); } | 945 bool is_resumable() const { |
| 946 return IsResumableFunction(function_state_->kind()); |
| 947 } |
948 | 948 |
949 // Report syntax errors. | 949 // Report syntax errors. |
950 void ReportMessage(MessageTemplate::Template message) { | 950 void ReportMessage(MessageTemplate::Template message) { |
951 Scanner::Location source_location = scanner()->location(); | 951 Scanner::Location source_location = scanner()->location(); |
952 impl()->ReportMessageAt(source_location, message, | 952 impl()->ReportMessageAt(source_location, message, |
953 static_cast<const char*>(nullptr), kSyntaxError); | 953 static_cast<const char*>(nullptr), kSyntaxError); |
954 } | 954 } |
955 | 955 |
956 template <typename T> | 956 template <typename T> |
957 void ReportMessage(MessageTemplate::Template message, T arg, | 957 void ReportMessage(MessageTemplate::Template message, T arg, |
(...skipping 4455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5413 has_seen_constructor_ = true; | 5413 has_seen_constructor_ = true; |
5414 return; | 5414 return; |
5415 } | 5415 } |
5416 } | 5416 } |
5417 | 5417 |
5418 | 5418 |
5419 } // namespace internal | 5419 } // namespace internal |
5420 } // namespace v8 | 5420 } // namespace v8 |
5421 | 5421 |
5422 #endif // V8_PARSING_PARSER_BASE_H | 5422 #endif // V8_PARSING_PARSER_BASE_H |
OLD | NEW |