| 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/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 FLAG_ACCESSOR(kToplevel, is_toplevel, set_toplevel) | 51 FLAG_ACCESSOR(kToplevel, is_toplevel, set_toplevel) |
| 52 FLAG_ACCESSOR(kLazy, is_lazy, set_lazy) | 52 FLAG_ACCESSOR(kLazy, is_lazy, set_lazy) |
| 53 FLAG_ACCESSOR(kEval, is_eval, set_eval) | 53 FLAG_ACCESSOR(kEval, is_eval, set_eval) |
| 54 FLAG_ACCESSOR(kGlobal, is_global, set_global) | 54 FLAG_ACCESSOR(kGlobal, is_global, set_global) |
| 55 FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode) | 55 FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode) |
| 56 FLAG_ACCESSOR(kNative, is_native, set_native) | 56 FLAG_ACCESSOR(kNative, is_native, set_native) |
| 57 FLAG_ACCESSOR(kModule, is_module, set_module) | 57 FLAG_ACCESSOR(kModule, is_module, set_module) |
| 58 FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing) | 58 FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing) |
| 59 FLAG_ACCESSOR(kAstValueFactoryOwned, ast_value_factory_owned, | 59 FLAG_ACCESSOR(kAstValueFactoryOwned, ast_value_factory_owned, |
| 60 set_ast_value_factory_owned) | 60 set_ast_value_factory_owned) |
| 61 FLAG_ACCESSOR(kIsNamedExpression, is_named_expression, |
| 62 set_is_named_expression) |
| 63 FLAG_ACCESSOR(kCallsEval, calls_eval, set_calls_eval) |
| 61 | 64 |
| 62 #undef FLAG_ACCESSOR | 65 #undef FLAG_ACCESSOR |
| 63 | 66 |
| 64 void set_parse_restriction(ParseRestriction restriction) { | 67 void set_parse_restriction(ParseRestriction restriction) { |
| 65 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION); | 68 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION); |
| 66 } | 69 } |
| 67 | 70 |
| 68 ParseRestriction parse_restriction() const { | 71 ParseRestriction parse_restriction() const { |
| 69 return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL | 72 return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL |
| 70 : NO_PARSE_RESTRICTION; | 73 : NO_PARSE_RESTRICTION; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void set_unicode_cache(UnicodeCache* unicode_cache) { | 122 void set_unicode_cache(UnicodeCache* unicode_cache) { |
| 120 unicode_cache_ = unicode_cache; | 123 unicode_cache_ = unicode_cache; |
| 121 } | 124 } |
| 122 | 125 |
| 123 uintptr_t stack_limit() { return stack_limit_; } | 126 uintptr_t stack_limit() { return stack_limit_; } |
| 124 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } | 127 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } |
| 125 | 128 |
| 126 uint32_t hash_seed() { return hash_seed_; } | 129 uint32_t hash_seed() { return hash_seed_; } |
| 127 void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } | 130 void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } |
| 128 | 131 |
| 132 int compiler_hints() const { return compiler_hints_; } |
| 133 void set_compiler_hints(int compiler_hints) { |
| 134 compiler_hints_ = compiler_hints; |
| 135 } |
| 136 |
| 137 int start_position() const { return start_position_; } |
| 138 void set_start_position(int start_position) { |
| 139 start_position_ = start_position; |
| 140 } |
| 141 |
| 142 int end_position() const { return end_position_; } |
| 143 void set_end_position(int end_position) { end_position_ = end_position; } |
| 144 |
| 145 // Getters for individual compiler hints. |
| 146 bool is_declaration() const; |
| 147 bool is_arrow() const; |
| 148 bool is_async() const; |
| 149 bool is_default_constructor() const; |
| 150 FunctionKind function_kind() const; |
| 151 |
| 129 //-------------------------------------------------------------------------- | 152 //-------------------------------------------------------------------------- |
| 130 // TODO(titzer): these should not be part of ParseInfo. | 153 // TODO(titzer): these should not be part of ParseInfo. |
| 131 //-------------------------------------------------------------------------- | 154 //-------------------------------------------------------------------------- |
| 132 Isolate* isolate() { return isolate_; } | 155 Isolate* isolate() { return isolate_; } |
| 133 Handle<SharedFunctionInfo> shared_info() { return shared_; } | 156 Handle<SharedFunctionInfo> shared_info() { return shared_; } |
| 134 Handle<Script> script() { return script_; } | 157 Handle<Script> script() { return script_; } |
| 135 Handle<Context> context() { return context_; } | 158 Handle<Context> context() { return context_; } |
| 136 void clear_script() { script_ = Handle<Script>::null(); } | 159 void clear_script() { script_ = Handle<Script>::null(); } |
| 137 void set_isolate(Isolate* isolate) { isolate_ = isolate; } | 160 void set_isolate(Isolate* isolate) { isolate_ = isolate; } |
| 138 void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; } | 161 void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 164 // ---------- Input flags --------------------------- | 187 // ---------- Input flags --------------------------- |
| 165 kToplevel = 1 << 0, | 188 kToplevel = 1 << 0, |
| 166 kLazy = 1 << 1, | 189 kLazy = 1 << 1, |
| 167 kEval = 1 << 2, | 190 kEval = 1 << 2, |
| 168 kGlobal = 1 << 3, | 191 kGlobal = 1 << 3, |
| 169 kStrictMode = 1 << 4, | 192 kStrictMode = 1 << 4, |
| 170 kNative = 1 << 5, | 193 kNative = 1 << 5, |
| 171 kParseRestriction = 1 << 6, | 194 kParseRestriction = 1 << 6, |
| 172 kModule = 1 << 7, | 195 kModule = 1 << 7, |
| 173 kAllowLazyParsing = 1 << 8, | 196 kAllowLazyParsing = 1 << 8, |
| 197 kIsNamedExpression = 1 << 9, |
| 198 kCallsEval = 1 << 10, |
| 174 // ---------- Output flags -------------------------- | 199 // ---------- Output flags -------------------------- |
| 175 kAstValueFactoryOwned = 1 << 9 | 200 kAstValueFactoryOwned = 1 << 11 |
| 176 }; | 201 }; |
| 177 | 202 |
| 178 //------------- Inputs to parsing and scope analysis ----------------------- | 203 //------------- Inputs to parsing and scope analysis ----------------------- |
| 179 Zone* zone_; | 204 Zone* zone_; |
| 180 unsigned flags_; | 205 unsigned flags_; |
| 181 ScriptCompiler::ExternalSourceStream* source_stream_; | 206 ScriptCompiler::ExternalSourceStream* source_stream_; |
| 182 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; | 207 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; |
| 183 Utf16CharacterStream* character_stream_; | 208 Utf16CharacterStream* character_stream_; |
| 184 v8::Extension* extension_; | 209 v8::Extension* extension_; |
| 185 ScriptCompiler::CompileOptions compile_options_; | 210 ScriptCompiler::CompileOptions compile_options_; |
| 186 Scope* script_scope_; | 211 Scope* script_scope_; |
| 187 UnicodeCache* unicode_cache_; | 212 UnicodeCache* unicode_cache_; |
| 188 uintptr_t stack_limit_; | 213 uintptr_t stack_limit_; |
| 189 uint32_t hash_seed_; | 214 uint32_t hash_seed_; |
| 215 int compiler_hints_; |
| 216 int start_position_; |
| 217 int end_position_; |
| 190 | 218 |
| 191 // TODO(titzer): Move handles and isolate out of ParseInfo. | 219 // TODO(titzer): Move handles and isolate out of ParseInfo. |
| 192 Isolate* isolate_; | 220 Isolate* isolate_; |
| 193 Handle<SharedFunctionInfo> shared_; | 221 Handle<SharedFunctionInfo> shared_; |
| 194 Handle<Script> script_; | 222 Handle<Script> script_; |
| 195 Handle<Context> context_; | 223 Handle<Context> context_; |
| 196 | 224 |
| 197 //----------- Inputs+Outputs of parsing and scope analysis ----------------- | 225 //----------- Inputs+Outputs of parsing and scope analysis ----------------- |
| 198 ScriptData** cached_data_; // used if available, populated if requested. | 226 ScriptData** cached_data_; // used if available, populated if requested. |
| 199 AstValueFactory* ast_value_factory_; // used if available, otherwise new. | 227 AstValueFactory* ast_value_factory_; // used if available, otherwise new. |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 // and we don't want too much user-controlled memory inside the code (this was | 771 // and we don't want too much user-controlled memory inside the code (this was |
| 744 // the reason why this limit was introduced in the first place; see | 772 // the reason why this limit was introduced in the first place; see |
| 745 // https://codereview.chromium.org/7003030/ ). | 773 // https://codereview.chromium.org/7003030/ ). |
| 746 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 | 774 static const int kMaxNumFunctionLocals = 4194303; // 2^22-1 |
| 747 | 775 |
| 748 // Returns NULL if parsing failed. | 776 // Returns NULL if parsing failed. |
| 749 FunctionLiteral* ParseProgram(Isolate* isolate, ParseInfo* info); | 777 FunctionLiteral* ParseProgram(Isolate* isolate, ParseInfo* info); |
| 750 | 778 |
| 751 FunctionLiteral* ParseLazy(Isolate* isolate, ParseInfo* info); | 779 FunctionLiteral* ParseLazy(Isolate* isolate, ParseInfo* info); |
| 752 FunctionLiteral* DoParseLazy(Isolate* isolate, ParseInfo* info, | 780 FunctionLiteral* DoParseLazy(Isolate* isolate, ParseInfo* info, |
| 781 const AstRawString* raw_name, |
| 753 Utf16CharacterStream* source); | 782 Utf16CharacterStream* source); |
| 754 | 783 |
| 755 // Called by ParseProgram after setting up the scanner. | 784 // Called by ParseProgram after setting up the scanner. |
| 756 FunctionLiteral* DoParseProgram(ParseInfo* info); | 785 FunctionLiteral* DoParseProgram(ParseInfo* info); |
| 757 | 786 |
| 758 void SetCachedData(ParseInfo* info); | 787 void SetCachedData(ParseInfo* info); |
| 759 | 788 |
| 760 ScriptCompiler::CompileOptions compile_options() const { | 789 ScriptCompiler::CompileOptions compile_options() const { |
| 761 return compile_options_; | 790 return compile_options_; |
| 762 } | 791 } |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 | 1355 |
| 1327 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1356 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
| 1328 return parser_->ParseDoExpression(ok); | 1357 return parser_->ParseDoExpression(ok); |
| 1329 } | 1358 } |
| 1330 | 1359 |
| 1331 | 1360 |
| 1332 } // namespace internal | 1361 } // namespace internal |
| 1333 } // namespace v8 | 1362 } // namespace v8 |
| 1334 | 1363 |
| 1335 #endif // V8_PARSING_PARSER_H_ | 1364 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |