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

Side by Side Diff: src/parsing/parser.h

Issue 2222503002: Revert of Remove redundant ParseInfo::scope_. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/compiler.cc ('k') | src/parsing/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_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 22 matching lines...) Expand all
33 ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared); 33 ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared);
34 34
35 ~ParseInfo() { 35 ~ParseInfo() {
36 if (ast_value_factory_owned()) { 36 if (ast_value_factory_owned()) {
37 delete ast_value_factory_; 37 delete ast_value_factory_;
38 set_ast_value_factory_owned(false); 38 set_ast_value_factory_owned(false);
39 } 39 }
40 ast_value_factory_ = nullptr; 40 ast_value_factory_ = nullptr;
41 } 41 }
42 42
43 Zone* zone() const { return zone_; } 43 Zone* zone() { return zone_; }
44 44
45 // Convenience accessor methods for flags. 45 // Convenience accessor methods for flags.
46 #define FLAG_ACCESSOR(flag, getter, setter) \ 46 #define FLAG_ACCESSOR(flag, getter, setter) \
47 bool getter() const { return GetFlag(flag); } \ 47 bool getter() const { return GetFlag(flag); } \
48 void setter() { SetFlag(flag); } \ 48 void setter() { SetFlag(flag); } \
49 void setter(bool val) { SetFlag(flag, val); } 49 void setter(bool val) { SetFlag(flag, val); }
50 50
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)
(...skipping 12 matching lines...) Expand all
66 66
67 void set_parse_restriction(ParseRestriction restriction) { 67 void set_parse_restriction(ParseRestriction restriction) {
68 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION); 68 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION);
69 } 69 }
70 70
71 ParseRestriction parse_restriction() const { 71 ParseRestriction parse_restriction() const {
72 return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL 72 return GetFlag(kParseRestriction) ? ONLY_SINGLE_FUNCTION_LITERAL
73 : NO_PARSE_RESTRICTION; 73 : NO_PARSE_RESTRICTION;
74 } 74 }
75 75
76 ScriptCompiler::ExternalSourceStream* source_stream() const { 76 ScriptCompiler::ExternalSourceStream* source_stream() {
77 return source_stream_; 77 return source_stream_;
78 } 78 }
79 void set_source_stream(ScriptCompiler::ExternalSourceStream* source_stream) { 79 void set_source_stream(ScriptCompiler::ExternalSourceStream* source_stream) {
80 source_stream_ = source_stream; 80 source_stream_ = source_stream;
81 } 81 }
82 82
83 ScriptCompiler::StreamedSource::Encoding source_stream_encoding() const { 83 ScriptCompiler::StreamedSource::Encoding source_stream_encoding() {
84 return source_stream_encoding_; 84 return source_stream_encoding_;
85 } 85 }
86 void set_source_stream_encoding( 86 void set_source_stream_encoding(
87 ScriptCompiler::StreamedSource::Encoding source_stream_encoding) { 87 ScriptCompiler::StreamedSource::Encoding source_stream_encoding) {
88 source_stream_encoding_ = source_stream_encoding; 88 source_stream_encoding_ = source_stream_encoding;
89 } 89 }
90 90
91 Utf16CharacterStream* character_stream() const { return character_stream_; } 91 Utf16CharacterStream* character_stream() const { return character_stream_; }
92 void set_character_stream(Utf16CharacterStream* character_stream) { 92 void set_character_stream(Utf16CharacterStream* character_stream) {
93 character_stream_ = character_stream; 93 character_stream_ = character_stream;
94 } 94 }
95 95
96 v8::Extension* extension() const { return extension_; } 96 v8::Extension* extension() { return extension_; }
97 void set_extension(v8::Extension* extension) { extension_ = extension; } 97 void set_extension(v8::Extension* extension) { extension_ = extension; }
98 98
99 ScriptData** cached_data() const { return cached_data_; } 99 ScriptData** cached_data() { return cached_data_; }
100 void set_cached_data(ScriptData** cached_data) { cached_data_ = cached_data; } 100 void set_cached_data(ScriptData** cached_data) { cached_data_ = cached_data; }
101 101
102 ScriptCompiler::CompileOptions compile_options() const { 102 ScriptCompiler::CompileOptions compile_options() { return compile_options_; }
103 return compile_options_;
104 }
105 void set_compile_options(ScriptCompiler::CompileOptions compile_options) { 103 void set_compile_options(ScriptCompiler::CompileOptions compile_options) {
106 compile_options_ = compile_options; 104 compile_options_ = compile_options;
107 } 105 }
108 106
109 DeclarationScope* script_scope() const { return script_scope_; } 107 DeclarationScope* script_scope() { return script_scope_; }
110 void set_script_scope(DeclarationScope* script_scope) { 108 void set_script_scope(DeclarationScope* script_scope) {
111 script_scope_ = script_scope; 109 script_scope_ = script_scope;
112 } 110 }
113 111
114 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } 112 AstValueFactory* ast_value_factory() { return ast_value_factory_; }
115 void set_ast_value_factory(AstValueFactory* ast_value_factory) { 113 void set_ast_value_factory(AstValueFactory* ast_value_factory) {
116 ast_value_factory_ = ast_value_factory; 114 ast_value_factory_ = ast_value_factory;
117 } 115 }
118 116
119 FunctionLiteral* literal() const { return literal_; } 117 FunctionLiteral* literal() { return literal_; }
120 void set_literal(FunctionLiteral* literal) { literal_ = literal; } 118 void set_literal(FunctionLiteral* literal) { literal_ = literal; }
121 119
122 DeclarationScope* scope() const { return literal()->scope(); } 120 DeclarationScope* scope() { return scope_; }
121 void set_scope(DeclarationScope* scope) { scope_ = scope; }
123 122
124 UnicodeCache* unicode_cache() const { return unicode_cache_; } 123 UnicodeCache* unicode_cache() { return unicode_cache_; }
125 void set_unicode_cache(UnicodeCache* unicode_cache) { 124 void set_unicode_cache(UnicodeCache* unicode_cache) {
126 unicode_cache_ = unicode_cache; 125 unicode_cache_ = unicode_cache;
127 } 126 }
128 127
129 uintptr_t stack_limit() const { return stack_limit_; } 128 uintptr_t stack_limit() { return stack_limit_; }
130 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } 129 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
131 130
132 uint32_t hash_seed() const { return hash_seed_; } 131 uint32_t hash_seed() { return hash_seed_; }
133 void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } 132 void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; }
134 133
135 int compiler_hints() const { return compiler_hints_; } 134 int compiler_hints() const { return compiler_hints_; }
136 void set_compiler_hints(int compiler_hints) { 135 void set_compiler_hints(int compiler_hints) {
137 compiler_hints_ = compiler_hints; 136 compiler_hints_ = compiler_hints;
138 } 137 }
139 138
140 int start_position() const { return start_position_; } 139 int start_position() const { return start_position_; }
141 void set_start_position(int start_position) { 140 void set_start_position(int start_position) {
142 start_position_ = start_position; 141 start_position_ = start_position;
143 } 142 }
144 143
145 int end_position() const { return end_position_; } 144 int end_position() const { return end_position_; }
146 void set_end_position(int end_position) { end_position_ = end_position; } 145 void set_end_position(int end_position) { end_position_ = end_position; }
147 146
148 // Getters for individual compiler hints. 147 // Getters for individual compiler hints.
149 bool is_declaration() const; 148 bool is_declaration() const;
150 bool is_arrow() const; 149 bool is_arrow() const;
151 bool is_async() const; 150 bool is_async() const;
152 bool is_default_constructor() const; 151 bool is_default_constructor() const;
153 FunctionKind function_kind() const; 152 FunctionKind function_kind() const;
154 153
155 //-------------------------------------------------------------------------- 154 //--------------------------------------------------------------------------
156 // TODO(titzer): these should not be part of ParseInfo. 155 // TODO(titzer): these should not be part of ParseInfo.
157 //-------------------------------------------------------------------------- 156 //--------------------------------------------------------------------------
158 Isolate* isolate() const { return isolate_; } 157 Isolate* isolate() { return isolate_; }
159 Handle<SharedFunctionInfo> shared_info() const { return shared_; } 158 Handle<SharedFunctionInfo> shared_info() { return shared_; }
160 Handle<Script> script() const { return script_; } 159 Handle<Script> script() { return script_; }
161 Handle<Context> context() const { return context_; } 160 Handle<Context> context() { return context_; }
162 void clear_script() { script_ = Handle<Script>::null(); } 161 void clear_script() { script_ = Handle<Script>::null(); }
163 void set_isolate(Isolate* isolate) { isolate_ = isolate; } 162 void set_isolate(Isolate* isolate) { isolate_ = isolate; }
164 void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; } 163 void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; }
165 void set_context(Handle<Context> context) { context_ = context; } 164 void set_context(Handle<Context> context) { context_ = context; }
166 void set_script(Handle<Script> script) { script_ = script; } 165 void set_script(Handle<Script> script) { script_ = script; }
167 //-------------------------------------------------------------------------- 166 //--------------------------------------------------------------------------
168 167
169 LanguageMode language_mode() const { 168 LanguageMode language_mode() {
170 return construct_language_mode(is_strict_mode()); 169 return construct_language_mode(is_strict_mode());
171 } 170 }
172 void set_language_mode(LanguageMode language_mode) { 171 void set_language_mode(LanguageMode language_mode) {
173 STATIC_ASSERT(LANGUAGE_END == 3); 172 STATIC_ASSERT(LANGUAGE_END == 3);
174 set_strict_mode(is_strict(language_mode)); 173 set_strict_mode(is_strict(language_mode));
175 } 174 }
176 175
177 void ReopenHandlesInNewHandleScope() { 176 void ReopenHandlesInNewHandleScope() {
178 shared_ = Handle<SharedFunctionInfo>(*shared_); 177 shared_ = Handle<SharedFunctionInfo>(*shared_);
179 script_ = Handle<Script>(*script_); 178 script_ = Handle<Script>(*script_);
180 context_ = Handle<Context>(*context_); 179 context_ = Handle<Context>(*context_);
181 } 180 }
182 181
183 #ifdef DEBUG 182 #ifdef DEBUG
184 bool script_is_native() const { 183 bool script_is_native() { return script_->type() == Script::TYPE_NATIVE; }
185 return script_->type() == Script::TYPE_NATIVE;
186 }
187 #endif // DEBUG 184 #endif // DEBUG
188 185
189 private: 186 private:
190 // Various configuration flags for parsing. 187 // Various configuration flags for parsing.
191 enum Flag { 188 enum Flag {
192 // ---------- Input flags --------------------------- 189 // ---------- Input flags ---------------------------
193 kToplevel = 1 << 0, 190 kToplevel = 1 << 0,
194 kLazy = 1 << 1, 191 kLazy = 1 << 1,
195 kEval = 1 << 2, 192 kEval = 1 << 2,
196 kGlobal = 1 << 3, 193 kGlobal = 1 << 3,
(...skipping 27 matching lines...) Expand all
224 // TODO(titzer): Move handles and isolate out of ParseInfo. 221 // TODO(titzer): Move handles and isolate out of ParseInfo.
225 Isolate* isolate_; 222 Isolate* isolate_;
226 Handle<SharedFunctionInfo> shared_; 223 Handle<SharedFunctionInfo> shared_;
227 Handle<Script> script_; 224 Handle<Script> script_;
228 Handle<Context> context_; 225 Handle<Context> context_;
229 226
230 //----------- Inputs+Outputs of parsing and scope analysis ----------------- 227 //----------- Inputs+Outputs of parsing and scope analysis -----------------
231 ScriptData** cached_data_; // used if available, populated if requested. 228 ScriptData** cached_data_; // used if available, populated if requested.
232 AstValueFactory* ast_value_factory_; // used if available, otherwise new. 229 AstValueFactory* ast_value_factory_; // used if available, otherwise new.
233 230
234 //----------- Output of parsing and scope analysis ------------------------ 231 //----------- Outputs of parsing and scope analysis ------------------------
235 FunctionLiteral* literal_; 232 FunctionLiteral* literal_; // produced by full parser.
233 DeclarationScope* scope_; // produced by scope analysis.
236 234
237 void SetFlag(Flag f) { flags_ |= f; } 235 void SetFlag(Flag f) { flags_ |= f; }
238 void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; } 236 void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; }
239 bool GetFlag(Flag f) const { return (flags_ & f) != 0; } 237 bool GetFlag(Flag f) const { return (flags_ & f) != 0; }
240 }; 238 };
241 239
242 class FunctionEntry BASE_EMBEDDED { 240 class FunctionEntry BASE_EMBEDDED {
243 public: 241 public:
244 enum { 242 enum {
245 kStartPositionIndex, 243 kStartPositionIndex,
(...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 1356
1359 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { 1357 DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
1360 return parser_->ParseDoExpression(ok); 1358 return parser_->ParseDoExpression(ok);
1361 } 1359 }
1362 1360
1363 1361
1364 } // namespace internal 1362 } // namespace internal
1365 } // namespace v8 1363 } // namespace v8
1366 1364
1367 #endif // V8_PARSING_PARSER_H_ 1365 #endif // V8_PARSING_PARSER_H_
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698