OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_PREPARSER_H | 28 #ifndef V8_PREPARSER_H |
29 #define V8_PREPARSER_H | 29 #define V8_PREPARSER_H |
30 | 30 |
31 #include "hashmap.h" | 31 #include "hashmap.h" |
32 #include "token.h" | 32 #include "token.h" |
33 #include "scanner.h" | 33 #include "scanner.h" |
34 | 34 |
35 namespace v8 { | 35 namespace v8 { |
36 | |
37 namespace internal { | 36 namespace internal { |
38 | 37 |
39 // Used to detect duplicates in object literals. Each of the values | 38 // Used to detect duplicates in object literals. Each of the values |
40 // kGetterProperty, kSetterProperty and kValueProperty represents | 39 // kGetterProperty, kSetterProperty and kValueProperty represents |
41 // a type of object literal property. When parsing a property, its | 40 // a type of object literal property. When parsing a property, its |
42 // type value is stored in the DuplicateFinder for the property name. | 41 // type value is stored in the DuplicateFinder for the property name. |
43 // Values are chosen so that having intersection bits means the there is | 42 // Values are chosen so that having intersection bits means the there is |
44 // an incompatibility. | 43 // an incompatibility. |
45 // I.e., you can add a getter to a property that already has a setter, since | 44 // I.e., you can add a getter to a property that already has a setter, since |
46 // kGetterProperty and kSetterProperty doesn't intersect, but not if it | 45 // kGetterProperty and kSetterProperty doesn't intersect, but not if it |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } else { | 117 } else { |
119 ASSERT(IsAccessorAccessorConflict(old_type, type)); | 118 ASSERT(IsAccessorAccessorConflict(old_type, type)); |
120 // Both accessors of the same type. | 119 // Both accessors of the same type. |
121 parser_->ReportMessageAt(scanner_->location(), | 120 parser_->ReportMessageAt(scanner_->location(), |
122 "accessor_get_set"); | 121 "accessor_get_set"); |
123 } | 122 } |
124 *ok = false; | 123 *ok = false; |
125 } | 124 } |
126 } | 125 } |
127 | 126 |
128 } // v8::internal | |
129 | |
130 namespace preparser { | |
131 | |
132 typedef uint8_t byte; | |
133 | 127 |
134 // Preparsing checks a JavaScript program and emits preparse-data that helps | 128 // Preparsing checks a JavaScript program and emits preparse-data that helps |
135 // a later parsing to be faster. | 129 // a later parsing to be faster. |
136 // See preparse-data-format.h for the data format. | 130 // See preparse-data-format.h for the data format. |
137 | 131 |
138 // The PreParser checks that the syntax follows the grammar for JavaScript, | 132 // The PreParser checks that the syntax follows the grammar for JavaScript, |
139 // and collects some information about the program along the way. | 133 // and collects some information about the program along the way. |
140 // The grammar check is only performed in order to understand the program | 134 // The grammar check is only performed in order to understand the program |
141 // sufficiently to deduce some information about it, that can be used | 135 // sufficiently to deduce some information about it, that can be used |
142 // to speed up later parsing. Finding errors is not the goal of pre-parsing, | 136 // to speed up later parsing. Finding errors is not the goal of pre-parsing, |
143 // rather it is to speed up properly written and correct programs. | 137 // rather it is to speed up properly written and correct programs. |
144 // That means that contextual checks (like a label being declared where | 138 // That means that contextual checks (like a label being declared where |
145 // it is used) are generally omitted. | 139 // it is used) are generally omitted. |
146 | 140 |
| 141 typedef uint8_t byte; |
147 namespace i = v8::internal; | 142 namespace i = v8::internal; |
148 | 143 |
149 class PreParser { | 144 class PreParser { |
150 public: | 145 public: |
151 enum PreParseResult { | 146 enum PreParseResult { |
152 kPreParseStackOverflow, | 147 kPreParseStackOverflow, |
153 kPreParseSuccess | 148 kPreParseSuccess |
154 }; | 149 }; |
155 | 150 |
156 | 151 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 bool stack_overflow_; | 681 bool stack_overflow_; |
687 bool allow_lazy_; | 682 bool allow_lazy_; |
688 bool allow_natives_syntax_; | 683 bool allow_natives_syntax_; |
689 bool allow_generators_; | 684 bool allow_generators_; |
690 bool allow_for_of_; | 685 bool allow_for_of_; |
691 bool parenthesized_function_; | 686 bool parenthesized_function_; |
692 | 687 |
693 friend class i::ObjectLiteralChecker<PreParser>; | 688 friend class i::ObjectLiteralChecker<PreParser>; |
694 }; | 689 }; |
695 | 690 |
696 } } // v8::preparser | 691 } } // v8::internal |
697 | 692 |
698 #endif // V8_PREPARSER_H | 693 #endif // V8_PREPARSER_H |
OLD | NEW |