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

Side by Side Diff: src/parser.h

Issue 894683003: Introduce LanguageMode, drop StrictMode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased (w/ conflicts) Created 5 years, 10 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 | « src/objects-inl.h ('k') | src/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_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 13 matching lines...) Expand all
24 class Target; 24 class Target;
25 25
26 26
27 class FunctionEntry BASE_EMBEDDED { 27 class FunctionEntry BASE_EMBEDDED {
28 public: 28 public:
29 enum { 29 enum {
30 kStartPositionIndex, 30 kStartPositionIndex,
31 kEndPositionIndex, 31 kEndPositionIndex,
32 kLiteralCountIndex, 32 kLiteralCountIndex,
33 kPropertyCountIndex, 33 kPropertyCountIndex,
34 kStrictModeIndex, 34 kLanguageModeIndex,
35 kSize 35 kSize
36 }; 36 };
37 37
38 explicit FunctionEntry(Vector<unsigned> backing) 38 explicit FunctionEntry(Vector<unsigned> backing)
39 : backing_(backing) { } 39 : backing_(backing) { }
40 40
41 FunctionEntry() : backing_() { } 41 FunctionEntry() : backing_() { }
42 42
43 int start_pos() { return backing_[kStartPositionIndex]; } 43 int start_pos() { return backing_[kStartPositionIndex]; }
44 int end_pos() { return backing_[kEndPositionIndex]; } 44 int end_pos() { return backing_[kEndPositionIndex]; }
45 int literal_count() { return backing_[kLiteralCountIndex]; } 45 int literal_count() { return backing_[kLiteralCountIndex]; }
46 int property_count() { return backing_[kPropertyCountIndex]; } 46 int property_count() { return backing_[kPropertyCountIndex]; }
47 StrictMode strict_mode() { 47 LanguageMode language_mode() {
48 DCHECK(backing_[kStrictModeIndex] == SLOPPY || 48 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex]));
49 backing_[kStrictModeIndex] == STRICT); 49 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]);
50 return static_cast<StrictMode>(backing_[kStrictModeIndex]);
51 } 50 }
52 51
53 bool is_valid() { return !backing_.is_empty(); } 52 bool is_valid() { return !backing_.is_empty(); }
54 53
55 private: 54 private:
56 Vector<unsigned> backing_; 55 Vector<unsigned> backing_;
57 }; 56 };
58 57
59 58
60 // Wrapper around ScriptData to provide parser-specific functionality. 59 // Wrapper around ScriptData to provide parser-specific functionality.
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 // function literal. Returns false (and deallocates any allocated AST 663 // function literal. Returns false (and deallocates any allocated AST
665 // nodes) if parsing failed. 664 // nodes) if parsing failed.
666 static bool Parse(CompilationInfo* info, 665 static bool Parse(CompilationInfo* info,
667 bool allow_lazy = false) { 666 bool allow_lazy = false) {
668 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(), 667 ParseInfo parse_info = {info->isolate()->stack_guard()->real_climit(),
669 info->isolate()->heap()->HashSeed(), 668 info->isolate()->heap()->HashSeed(),
670 info->isolate()->unicode_cache()}; 669 info->isolate()->unicode_cache()};
671 Parser parser(info, &parse_info); 670 Parser parser(info, &parse_info);
672 parser.set_allow_lazy(allow_lazy); 671 parser.set_allow_lazy(allow_lazy);
673 if (parser.Parse()) { 672 if (parser.Parse()) {
674 info->SetStrictMode(info->function()->strict_mode()); 673 info->SetLanguageMode(info->function()->language_mode());
675 return true; 674 return true;
676 } 675 }
677 return false; 676 return false;
678 } 677 }
679 bool Parse(); 678 bool Parse();
680 void ParseOnBackground(); 679 void ParseOnBackground();
681 680
682 // Handle errors detected during parsing, move statistics to Isolate, 681 // Handle errors detected during parsing, move statistics to Isolate,
683 // internalize strings (move them to the heap). 682 // internalize strings (move them to the heap).
684 void Internalize(); 683 void Internalize();
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 } 997 }
999 998
1000 999
1001 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state, 1000 Expression* ParserTraits::CloseTemplateLiteral(TemplateLiteralState* state,
1002 int start, Expression* tag) { 1001 int start, Expression* tag) {
1003 return parser_->CloseTemplateLiteral(state, start, tag); 1002 return parser_->CloseTemplateLiteral(state, start, tag);
1004 } 1003 }
1005 } } // namespace v8::internal 1004 } } // namespace v8::internal
1006 1005
1007 #endif // V8_PARSER_H_ 1006 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698