OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_PARSE_INFO_H_ | 5 #ifndef V8_PARSING_PARSE_INFO_H_ |
6 #define V8_PARSING_PARSE_INFO_H_ | 6 #define V8_PARSING_PARSE_INFO_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "include/v8.h" | 10 #include "include/v8.h" |
11 #include "src/globals.h" | 11 #include "src/globals.h" |
12 #include "src/handles.h" | 12 #include "src/handles.h" |
13 #include "src/parsing/preparsed-scope-data.h" | 13 #include "src/parsing/preparsed-scope-data.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 | 16 |
17 class Extension; | 17 class Extension; |
18 | 18 |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 class AccountingAllocator; | 21 class AccountingAllocator; |
22 class AstRawString; | 22 class AstRawString; |
23 class AstValueFactory; | 23 class AstValueFactory; |
24 class DeclarationScope; | 24 class DeclarationScope; |
25 class DeferredHandles; | |
26 class FunctionLiteral; | 25 class FunctionLiteral; |
27 class ScriptData; | 26 class ScriptData; |
28 class SharedFunctionInfo; | 27 class SharedFunctionInfo; |
29 class UnicodeCache; | 28 class UnicodeCache; |
30 class Utf16CharacterStream; | 29 class Utf16CharacterStream; |
31 class Zone; | 30 class Zone; |
32 | 31 |
33 // A container for the inputs, configuration options, and outputs of parsing. | 32 // A container for the inputs, configuration options, and outputs of parsing. |
34 class V8_EXPORT_PRIVATE ParseInfo { | 33 class V8_EXPORT_PRIVATE ParseInfo { |
35 public: | 34 public: |
36 explicit ParseInfo(AccountingAllocator* zone_allocator); | 35 explicit ParseInfo(AccountingAllocator* zone_allocator); |
37 ParseInfo(Handle<Script> script); | 36 ParseInfo(Handle<Script> script); |
38 ParseInfo(Handle<SharedFunctionInfo> shared); | 37 ParseInfo(Handle<SharedFunctionInfo> shared); |
39 | 38 |
40 // TODO(rmcilroy): Remove once Hydrogen no longer needs this. | 39 // TODO(rmcilroy): Remove once Hydrogen no longer needs this. |
41 ParseInfo(Handle<SharedFunctionInfo> shared, std::shared_ptr<Zone> zone); | 40 ParseInfo(Handle<SharedFunctionInfo> shared, std::shared_ptr<Zone> zone); |
42 | 41 |
43 ~ParseInfo(); | 42 ~ParseInfo(); |
44 | 43 |
45 Zone* zone() const { return zone_.get(); } | 44 Zone* zone() const { return zone_.get(); } |
46 | 45 |
47 std::shared_ptr<Zone> zone_shared() const { return zone_; } | 46 std::shared_ptr<Zone> zone_shared() const { return zone_; } |
48 | 47 |
49 void set_deferred_handles(std::shared_ptr<DeferredHandles> deferred_handles); | |
50 void set_deferred_handles(DeferredHandles* deferred_handles); | |
51 std::shared_ptr<DeferredHandles> deferred_handles() const { | |
52 return deferred_handles_; | |
53 } | |
54 | |
55 // Convenience accessor methods for flags. | 48 // Convenience accessor methods for flags. |
56 #define FLAG_ACCESSOR(flag, getter, setter) \ | 49 #define FLAG_ACCESSOR(flag, getter, setter) \ |
57 bool getter() const { return GetFlag(flag); } \ | 50 bool getter() const { return GetFlag(flag); } \ |
58 void setter() { SetFlag(flag); } \ | 51 void setter() { SetFlag(flag); } \ |
59 void setter(bool val) { SetFlag(flag, val); } | 52 void setter(bool val) { SetFlag(flag, val); } |
60 | 53 |
61 FLAG_ACCESSOR(kToplevel, is_toplevel, set_toplevel) | 54 FLAG_ACCESSOR(kToplevel, is_toplevel, set_toplevel) |
62 FLAG_ACCESSOR(kEval, is_eval, set_eval) | 55 FLAG_ACCESSOR(kEval, is_eval, set_eval) |
63 FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode) | 56 FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode) |
64 FLAG_ACCESSOR(kNative, is_native, set_native) | 57 FLAG_ACCESSOR(kNative, is_native, set_native) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 194 |
202 LanguageMode language_mode() const { | 195 LanguageMode language_mode() const { |
203 return construct_language_mode(is_strict_mode()); | 196 return construct_language_mode(is_strict_mode()); |
204 } | 197 } |
205 void set_language_mode(LanguageMode language_mode) { | 198 void set_language_mode(LanguageMode language_mode) { |
206 STATIC_ASSERT(LANGUAGE_END == 2); | 199 STATIC_ASSERT(LANGUAGE_END == 2); |
207 set_strict_mode(is_strict(language_mode)); | 200 set_strict_mode(is_strict(language_mode)); |
208 } | 201 } |
209 | 202 |
210 void ReopenHandlesInNewHandleScope() { | 203 void ReopenHandlesInNewHandleScope() { |
211 if (!script_.is_null()) { | 204 shared_ = Handle<SharedFunctionInfo>(*shared_); |
212 script_ = Handle<Script>(*script_); | 205 script_ = Handle<Script>(*script_); |
213 } | |
214 if (!shared_.is_null()) { | |
215 shared_ = Handle<SharedFunctionInfo>(*shared_); | |
216 } | |
217 Handle<ScopeInfo> outer_scope_info; | 206 Handle<ScopeInfo> outer_scope_info; |
218 if (maybe_outer_scope_info_.ToHandle(&outer_scope_info)) { | 207 if (maybe_outer_scope_info_.ToHandle(&outer_scope_info)) { |
219 maybe_outer_scope_info_ = Handle<ScopeInfo>(*outer_scope_info); | 208 maybe_outer_scope_info_ = Handle<ScopeInfo>(*outer_scope_info); |
220 } | 209 } |
221 } | 210 } |
222 | 211 |
223 #ifdef DEBUG | 212 #ifdef DEBUG |
224 bool script_is_native() const; | 213 bool script_is_native() const; |
225 #endif // DEBUG | 214 #endif // DEBUG |
226 | 215 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 MaybeHandle<ScopeInfo> maybe_outer_scope_info_; | 259 MaybeHandle<ScopeInfo> maybe_outer_scope_info_; |
271 | 260 |
272 //----------- Inputs+Outputs of parsing and scope analysis ----------------- | 261 //----------- Inputs+Outputs of parsing and scope analysis ----------------- |
273 ScriptData** cached_data_; // used if available, populated if requested. | 262 ScriptData** cached_data_; // used if available, populated if requested. |
274 PreParsedScopeData preparsed_scope_data_; | 263 PreParsedScopeData preparsed_scope_data_; |
275 AstValueFactory* ast_value_factory_; // used if available, otherwise new. | 264 AstValueFactory* ast_value_factory_; // used if available, otherwise new. |
276 const AstRawString* function_name_; | 265 const AstRawString* function_name_; |
277 | 266 |
278 //----------- Output of parsing and scope analysis ------------------------ | 267 //----------- Output of parsing and scope analysis ------------------------ |
279 FunctionLiteral* literal_; | 268 FunctionLiteral* literal_; |
280 std::shared_ptr<DeferredHandles> deferred_handles_; | |
281 | 269 |
282 void SetFlag(Flag f) { flags_ |= f; } | 270 void SetFlag(Flag f) { flags_ |= f; } |
283 void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; } | 271 void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; } |
284 bool GetFlag(Flag f) const { return (flags_ & f) != 0; } | 272 bool GetFlag(Flag f) const { return (flags_ & f) != 0; } |
285 }; | 273 }; |
286 | 274 |
287 } // namespace internal | 275 } // namespace internal |
288 } // namespace v8 | 276 } // namespace v8 |
289 | 277 |
290 #endif // V8_PARSING_PARSE_INFO_H_ | 278 #endif // V8_PARSING_PARSE_INFO_H_ |
OLD | NEW |