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

Side by Side Diff: src/parsing/parser.h

Issue 2301923002: ParserBase: Simplify FuncNameInferrer handling. (Closed)
Patch Set: code review (nikolaos@) Created 4 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
« no previous file with comments | « no previous file | src/parsing/parser.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_PARSING_PARSER_H_ 5 #ifndef V8_PARSING_PARSER_H_
6 #define V8_PARSING_PARSER_H_ 6 #define V8_PARSING_PARSER_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/parsing/parser-base.h" 10 #include "src/parsing/parser-base.h"
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 return string->AsArrayIndex(index); 702 return string->AsArrayIndex(index);
703 } 703 }
704 704
705 V8_INLINE static Expression* GetPropertyValue( 705 V8_INLINE static Expression* GetPropertyValue(
706 ObjectLiteral::Property* property) { 706 ObjectLiteral::Property* property) {
707 return property->value(); 707 return property->value();
708 } 708 }
709 709
710 // Functions for encapsulating the differences between parsing and preparsing; 710 // Functions for encapsulating the differences between parsing and preparsing;
711 // operations interleaved with the recursive descent. 711 // operations interleaved with the recursive descent.
712 V8_INLINE static void PushLiteralName(FuncNameInferrer* fni, 712 V8_INLINE void PushLiteralName(const AstRawString* id) {
713 const AstRawString* id) { 713 DCHECK_NOT_NULL(fni_);
714 fni->PushLiteralName(id); 714 fni_->PushLiteralName(id);
715 } 715 }
716 716
717 V8_INLINE static void PushVariableName(FuncNameInferrer* fni, 717 V8_INLINE void PushVariableName(const AstRawString* id) {
718 const AstRawString* id) { 718 DCHECK_NOT_NULL(fni_);
719 fni->PushVariableName(id); 719 fni_->PushVariableName(id);
720 } 720 }
721 721
722 V8_INLINE void PushPropertyName(FuncNameInferrer* fni, 722 V8_INLINE void PushPropertyName(Expression* expression) {
723 Expression* expression) { 723 DCHECK_NOT_NULL(fni_);
724 if (expression->IsPropertyName()) { 724 if (expression->IsPropertyName()) {
725 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); 725 fni_->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
726 } else { 726 } else {
727 fni->PushLiteralName(ast_value_factory()->anonymous_function_string()); 727 fni_->PushLiteralName(ast_value_factory()->anonymous_function_string());
728 } 728 }
729 } 729 }
730 730
731 V8_INLINE static void InferFunctionName(FuncNameInferrer* fni, 731 V8_INLINE void InferFunctionName(FunctionLiteral* func_to_infer) {
732 FunctionLiteral* func_to_infer) { 732 fni_->AddFunction(func_to_infer);
733 fni->AddFunction(func_to_infer);
734 } 733 }
735 734
736 // If we assign a function literal to a property we pretenure the 735 // If we assign a function literal to a property we pretenure the
737 // literal so it can be added as a constant function property. 736 // literal so it can be added as a constant function property.
738 V8_INLINE static void CheckAssigningFunctionLiteralToProperty( 737 V8_INLINE static void CheckAssigningFunctionLiteralToProperty(
739 Expression* left, Expression* right) { 738 Expression* left, Expression* right) {
740 DCHECK(left != NULL); 739 DCHECK(left != NULL);
741 if (left->IsProperty() && right->IsFunctionLiteral()) { 740 if (left->IsProperty() && right->IsFunctionLiteral()) {
742 right->AsFunctionLiteral()->set_pretenure(); 741 right->AsFunctionLiteral()->set_pretenure();
743 } 742 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 Expression* NewSuperPropertyReference(int pos); 885 Expression* NewSuperPropertyReference(int pos);
887 Expression* NewSuperCallReference(int pos); 886 Expression* NewSuperCallReference(int pos);
888 Expression* NewTargetExpression(int pos); 887 Expression* NewTargetExpression(int pos);
889 Expression* FunctionSentExpression(int pos); 888 Expression* FunctionSentExpression(int pos);
890 889
891 Literal* ExpressionFromLiteral(Token::Value token, int pos); 890 Literal* ExpressionFromLiteral(Token::Value token, int pos);
892 891
893 V8_INLINE Expression* ExpressionFromIdentifier( 892 V8_INLINE Expression* ExpressionFromIdentifier(
894 const AstRawString* name, int start_position, int end_position, 893 const AstRawString* name, int start_position, int end_position,
895 InferName infer = InferName::kYes) { 894 InferName infer = InferName::kYes) {
896 if (infer == InferName::kYes && fni_ != NULL) { 895 if (infer == InferName::kYes) {
897 fni_->PushVariableName(name); 896 fni_->PushVariableName(name);
898 } 897 }
899 return NewUnresolved(name, start_position, end_position); 898 return NewUnresolved(name, start_position, end_position);
900 } 899 }
901 900
902 V8_INLINE Expression* ExpressionFromString(int pos) { 901 V8_INLINE Expression* ExpressionFromString(int pos) {
903 const AstRawString* symbol = GetSymbol(); 902 const AstRawString* symbol = GetSymbol();
904 if (fni_ != NULL) fni_->PushLiteralName(symbol); 903 fni_->PushLiteralName(symbol);
905 return factory()->NewStringLiteral(symbol, pos); 904 return factory()->NewStringLiteral(symbol, pos);
906 } 905 }
907 906
908 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const { 907 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const {
909 return new (zone()) ZoneList<Expression*>(size, zone()); 908 return new (zone()) ZoneList<Expression*>(size, zone());
910 } 909 }
911 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList( 910 V8_INLINE ZoneList<ObjectLiteral::Property*>* NewPropertyList(
912 int size) const { 911 int size) const {
913 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone()); 912 return new (zone()) ZoneList<ObjectLiteral::Property*>(size, zone());
914 } 913 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 static const int kLiteralTypeSlot = 0; 1054 static const int kLiteralTypeSlot = 0;
1056 static const int kElementsSlot = 1; 1055 static const int kElementsSlot = 1;
1057 1056
1058 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue); 1057 DISALLOW_IMPLICIT_CONSTRUCTORS(CompileTimeValue);
1059 }; 1058 };
1060 1059
1061 } // namespace internal 1060 } // namespace internal
1062 } // namespace v8 1061 } // namespace v8
1063 1062
1064 #endif // V8_PARSING_PARSER_H_ 1063 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698