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_PARSER_H_ | 5 #ifndef V8_PARSER_H_ |
6 #define V8_PARSER_H_ | 6 #define V8_PARSER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/compiler.h" // For CachedDataMode | 10 #include "src/compiler.h" // For CachedDataMode |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 647 |
648 // Parses the source code represented by the compilation info and sets its | 648 // Parses the source code represented by the compilation info and sets its |
649 // function literal. Returns false (and deallocates any allocated AST | 649 // function literal. Returns false (and deallocates any allocated AST |
650 // nodes) if parsing failed. | 650 // nodes) if parsing failed. |
651 static bool ParseStatic(CompilationInfo* info, bool allow_lazy = false); | 651 static bool ParseStatic(CompilationInfo* info, bool allow_lazy = false); |
652 bool Parse(CompilationInfo* info); | 652 bool Parse(CompilationInfo* info); |
653 void ParseOnBackground(CompilationInfo* info); | 653 void ParseOnBackground(CompilationInfo* info); |
654 | 654 |
655 // Handle errors detected during parsing, move statistics to Isolate, | 655 // Handle errors detected during parsing, move statistics to Isolate, |
656 // internalize strings (move them to the heap). | 656 // internalize strings (move them to the heap). |
657 void Internalize(CompilationInfo* info); | 657 void Internalize(Isolate* isolate, Handle<Script> script, bool error); |
658 void HandleSourceURLComments(CompilationInfo* info); | 658 void HandleSourceURLComments(Isolate* isolate, Handle<Script> script); |
659 | 659 |
660 private: | 660 private: |
661 friend class ParserTraits; | 661 friend class ParserTraits; |
662 | 662 |
663 // Limit the allowed number of local variables in a function. The hard limit | 663 // Limit the allowed number of local variables in a function. The hard limit |
664 // is that offsets computed by FullCodeGenerator::StackOperand and similar | 664 // is that offsets computed by FullCodeGenerator::StackOperand and similar |
665 // functions are ints, and they should not overflow. In addition, accessing | 665 // functions are ints, and they should not overflow. In addition, accessing |
666 // local variables creates user-controlled constants in the generated code, | 666 // local variables creates user-controlled constants in the generated code, |
667 // and we don't want too much user-controlled memory inside the code (this was | 667 // and we don't want too much user-controlled memory inside the code (this was |
668 // the reason why this limit was introduced in the first place; see | 668 // the reason why this limit was introduced in the first place; see |
669 // https://codereview.chromium.org/7003030/ ). | 669 // https://codereview.chromium.org/7003030/ ). |
670 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 | 670 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 |
671 | 671 |
672 // Returns NULL if parsing failed. | 672 // Returns NULL if parsing failed. |
673 FunctionLiteral* ParseProgram(CompilationInfo* info); | 673 FunctionLiteral* ParseProgram(Isolate* isolate, CompilationInfo* info); |
674 | 674 |
675 FunctionLiteral* ParseLazy(CompilationInfo* info); | 675 FunctionLiteral* ParseLazy(Isolate* isolate, CompilationInfo* info); |
676 FunctionLiteral* ParseLazy(CompilationInfo* info, | 676 FunctionLiteral* ParseLazy(Isolate* isolate, CompilationInfo* info, |
677 Utf16CharacterStream* source); | 677 Utf16CharacterStream* source); |
678 | 678 |
679 // Called by ParseProgram after setting up the scanner. | 679 // Called by ParseProgram after setting up the scanner. |
680 FunctionLiteral* DoParseProgram(CompilationInfo* info, Scope** scope, | 680 FunctionLiteral* DoParseProgram(CompilationInfo* info, Scope** scope, |
681 Scope** ad_hoc_eval_scope); | 681 Scope** ad_hoc_eval_scope); |
682 | 682 |
683 void SetCachedData(CompilationInfo* info); | 683 void SetCachedData(CompilationInfo* info); |
684 | 684 |
685 bool inside_with() const { return scope_->inside_with(); } | 685 bool inside_with() const { return scope_->inside_with(); } |
686 ScriptCompiler::CompileOptions compile_options() const { | 686 ScriptCompiler::CompileOptions compile_options() const { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 } | 947 } |
948 | 948 |
949 | 949 |
950 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, | 950 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, |
951 int start, Expression* tag) { | 951 int start, Expression* tag) { |
952 return parser_->CloseTemplateLiteral(state, start, tag); | 952 return parser_->CloseTemplateLiteral(state, start, tag); |
953 } | 953 } |
954 } } // namespace v8::internal | 954 } } // namespace v8::internal |
955 | 955 |
956 #endif // V8_PARSER_H_ | 956 #endif // V8_PARSER_H_ |
OLD | NEW |