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_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/base/compiler-specific.h" | 10 #include "src/base/compiler-specific.h" |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); | 456 void CheckConflictingVarDeclarations(Scope* scope, bool* ok); |
457 | 457 |
458 // Insert initializer statements for var-bindings shadowing parameter bindings | 458 // Insert initializer statements for var-bindings shadowing parameter bindings |
459 // from a non-simple parameter list. | 459 // from a non-simple parameter list. |
460 void InsertShadowingVarBindingInitializers(Block* block); | 460 void InsertShadowingVarBindingInitializers(Block* block); |
461 | 461 |
462 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 | 462 // Implement sloppy block-scoped functions, ES2015 Annex B 3.3 |
463 void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope); | 463 void InsertSloppyBlockFunctionVarBindings(DeclarationScope* scope); |
464 | 464 |
465 VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos, | 465 VariableProxy* NewUnresolved(const AstRawString* name, int begin_pos, |
466 int end_pos = kNoSourcePosition, | |
467 VariableKind kind = NORMAL_VARIABLE); | 466 VariableKind kind = NORMAL_VARIABLE); |
468 VariableProxy* NewUnresolved(const AstRawString* name); | 467 VariableProxy* NewUnresolved(const AstRawString* name); |
469 Variable* Declare(Declaration* declaration, | 468 Variable* Declare(Declaration* declaration, |
470 DeclarationDescriptor::Kind declaration_kind, | 469 DeclarationDescriptor::Kind declaration_kind, |
471 VariableMode mode, InitializationFlag init, bool* ok, | 470 VariableMode mode, InitializationFlag init, bool* ok, |
472 Scope* declaration_scope = nullptr); | 471 Scope* declaration_scope = nullptr); |
473 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, | 472 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, |
474 int pos, bool* ok); | 473 int pos, bool* ok); |
475 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, | 474 Declaration* DeclareVariable(const AstRawString* name, VariableMode mode, |
476 InitializationFlag init, int pos, bool* ok); | 475 InitializationFlag init, int pos, bool* ok); |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 } | 924 } |
926 | 925 |
927 V8_INLINE const AstRawString* GetNumberAsSymbol() const { | 926 V8_INLINE const AstRawString* GetNumberAsSymbol() const { |
928 double double_value = scanner()->DoubleValue(); | 927 double double_value = scanner()->DoubleValue(); |
929 char array[100]; | 928 char array[100]; |
930 const char* string = DoubleToCString(double_value, ArrayVector(array)); | 929 const char* string = DoubleToCString(double_value, ArrayVector(array)); |
931 return ast_value_factory()->GetOneByteString(string); | 930 return ast_value_factory()->GetOneByteString(string); |
932 } | 931 } |
933 | 932 |
934 V8_INLINE Expression* ThisExpression(int pos = kNoSourcePosition) { | 933 V8_INLINE Expression* ThisExpression(int pos = kNoSourcePosition) { |
935 return NewUnresolved(ast_value_factory()->this_string(), pos, pos + 4, | 934 return NewUnresolved(ast_value_factory()->this_string(), pos, |
936 THIS_VARIABLE); | 935 THIS_VARIABLE); |
937 } | 936 } |
938 | 937 |
939 Expression* NewSuperPropertyReference(int pos); | 938 Expression* NewSuperPropertyReference(int pos); |
940 Expression* NewSuperCallReference(int pos); | 939 Expression* NewSuperCallReference(int pos); |
941 Expression* NewTargetExpression(int pos); | 940 Expression* NewTargetExpression(int pos); |
942 Expression* FunctionSentExpression(int pos); | 941 Expression* FunctionSentExpression(int pos); |
943 | 942 |
944 Literal* ExpressionFromLiteral(Token::Value token, int pos); | 943 Literal* ExpressionFromLiteral(Token::Value token, int pos); |
945 | 944 |
946 V8_INLINE Expression* ExpressionFromIdentifier( | 945 V8_INLINE Expression* ExpressionFromIdentifier( |
947 const AstRawString* name, int start_position, int end_position, | 946 const AstRawString* name, int start_position, |
948 InferName infer = InferName::kYes) { | 947 InferName infer = InferName::kYes) { |
949 if (infer == InferName::kYes) { | 948 if (infer == InferName::kYes) { |
950 fni_->PushVariableName(name); | 949 fni_->PushVariableName(name); |
951 } | 950 } |
952 return NewUnresolved(name, start_position, end_position); | 951 return NewUnresolved(name, start_position); |
953 } | 952 } |
954 | 953 |
955 V8_INLINE Expression* ExpressionFromString(int pos) { | 954 V8_INLINE Expression* ExpressionFromString(int pos) { |
956 const AstRawString* symbol = GetSymbol(); | 955 const AstRawString* symbol = GetSymbol(); |
957 fni_->PushLiteralName(symbol); | 956 fni_->PushLiteralName(symbol); |
958 return factory()->NewStringLiteral(symbol, pos); | 957 return factory()->NewStringLiteral(symbol, pos); |
959 } | 958 } |
960 | 959 |
961 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const { | 960 V8_INLINE ZoneList<Expression*>* NewExpressionList(int size) const { |
962 return new (zone()) ZoneList<Expression*>(size, zone()); | 961 return new (zone()) ZoneList<Expression*>(size, zone()); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 | 1141 |
1143 private: | 1142 private: |
1144 ParserTarget** variable_; | 1143 ParserTarget** variable_; |
1145 ParserTarget* previous_; | 1144 ParserTarget* previous_; |
1146 }; | 1145 }; |
1147 | 1146 |
1148 } // namespace internal | 1147 } // namespace internal |
1149 } // namespace v8 | 1148 } // namespace v8 |
1150 | 1149 |
1151 #endif // V8_PARSING_PARSER_H_ | 1150 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |