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 #include "src/parsing/parse-info.h" | 5 #include "src/parsing/parse-info.h" |
6 | 6 |
7 #include "src/ast/ast-value-factory.h" | 7 #include "src/ast/ast-value-factory.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 ParseInfo::ParseInfo(Zone* zone) | 13 ParseInfo::ParseInfo(Zone* zone) |
marja
2016/10/12 11:58:57
Why not also set is_toplevel here?
Then the backg
Toon Verwaest
2016/10/12 12:17:53
Why is that a better default? Note that in the oth
| |
14 : zone_(zone), | 14 : zone_(zone), |
15 flags_(0), | 15 flags_(0), |
16 source_stream_(nullptr), | 16 source_stream_(nullptr), |
17 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), | 17 source_stream_encoding_(ScriptCompiler::StreamedSource::ONE_BYTE), |
18 character_stream_(nullptr), | 18 character_stream_(nullptr), |
19 extension_(nullptr), | 19 extension_(nullptr), |
20 compile_options_(ScriptCompiler::kNoCompileOptions), | 20 compile_options_(ScriptCompiler::kNoCompileOptions), |
21 script_scope_(nullptr), | 21 script_scope_(nullptr), |
22 unicode_cache_(nullptr), | 22 unicode_cache_(nullptr), |
23 stack_limit_(0), | 23 stack_limit_(0), |
24 hash_seed_(0), | 24 hash_seed_(0), |
25 compiler_hints_(0), | 25 compiler_hints_(0), |
26 start_position_(0), | 26 start_position_(0), |
27 end_position_(0), | 27 end_position_(0), |
28 isolate_(nullptr), | 28 isolate_(nullptr), |
29 cached_data_(nullptr), | 29 cached_data_(nullptr), |
30 ast_value_factory_(nullptr), | 30 ast_value_factory_(nullptr), |
31 function_name_(nullptr), | 31 function_name_(nullptr), |
32 literal_(nullptr) {} | 32 literal_(nullptr) {} |
33 | 33 |
34 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function) | 34 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function) |
35 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {} | 35 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {} |
36 | 36 |
37 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) | 37 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) |
38 : ParseInfo(zone) { | 38 : ParseInfo(zone) { |
39 isolate_ = shared->GetIsolate(); | 39 isolate_ = shared->GetIsolate(); |
40 | 40 |
41 if (shared->is_toplevel()) set_toplevel(); | |
41 set_allow_lazy_parsing(FLAG_lazy_inner_functions); | 42 set_allow_lazy_parsing(FLAG_lazy_inner_functions); |
42 set_hash_seed(isolate_->heap()->HashSeed()); | 43 set_hash_seed(isolate_->heap()->HashSeed()); |
43 set_is_named_expression(shared->is_named_expression()); | 44 set_is_named_expression(shared->is_named_expression()); |
44 set_calls_eval(shared->scope_info()->CallsEval()); | 45 set_calls_eval(shared->scope_info()->CallsEval()); |
45 set_compiler_hints(shared->compiler_hints()); | 46 set_compiler_hints(shared->compiler_hints()); |
46 set_start_position(shared->start_position()); | 47 set_start_position(shared->start_position()); |
47 set_end_position(shared->end_position()); | 48 set_end_position(shared->end_position()); |
48 set_stack_limit(isolate_->stack_guard()->real_climit()); | 49 set_stack_limit(isolate_->stack_guard()->real_climit()); |
49 set_unicode_cache(isolate_->unicode_cache()); | 50 set_unicode_cache(isolate_->unicode_cache()); |
50 set_language_mode(shared->language_mode()); | 51 set_language_mode(shared->language_mode()); |
51 set_shared_info(shared); | 52 set_shared_info(shared); |
52 | 53 |
53 Handle<Script> script(Script::cast(shared->script())); | 54 Handle<Script> script(Script::cast(shared->script())); |
54 set_script(script); | 55 set_script(script); |
55 if (!script.is_null() && script->type() == Script::TYPE_NATIVE) { | 56 if (!script.is_null() && script->type() == Script::TYPE_NATIVE) { |
56 set_native(); | 57 set_native(); |
57 } | 58 } |
58 | 59 |
59 Handle<HeapObject> scope_info(shared->outer_scope_info()); | 60 Handle<HeapObject> scope_info(shared->outer_scope_info()); |
60 if (!scope_info->IsTheHole(isolate()) && | 61 if (!scope_info->IsTheHole(isolate()) && |
61 Handle<ScopeInfo>::cast(scope_info)->length() > 0) { | 62 Handle<ScopeInfo>::cast(scope_info)->length() > 0) { |
62 set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info)); | 63 set_outer_scope_info(Handle<ScopeInfo>::cast(scope_info)); |
63 } | 64 } |
64 } | 65 } |
65 | 66 |
66 ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) { | 67 ParseInfo::ParseInfo(Zone* zone, Handle<Script> script) : ParseInfo(zone) { |
67 isolate_ = script->GetIsolate(); | 68 isolate_ = script->GetIsolate(); |
68 | 69 |
70 set_toplevel(); | |
marja
2016/10/12 11:58:57
... and then this can go away since it's set in th
| |
69 set_hash_seed(isolate_->heap()->HashSeed()); | 71 set_hash_seed(isolate_->heap()->HashSeed()); |
70 set_stack_limit(isolate_->stack_guard()->real_climit()); | 72 set_stack_limit(isolate_->stack_guard()->real_climit()); |
71 set_unicode_cache(isolate_->unicode_cache()); | 73 set_unicode_cache(isolate_->unicode_cache()); |
72 set_script(script); | 74 set_script(script); |
73 | 75 |
74 if (script->type() == Script::TYPE_NATIVE) { | 76 if (script->type() == Script::TYPE_NATIVE) { |
75 set_native(); | 77 set_native(); |
76 } | 78 } |
77 } | 79 } |
78 | 80 |
(...skipping 25 matching lines...) Expand all Loading... | |
104 } | 106 } |
105 | 107 |
106 #ifdef DEBUG | 108 #ifdef DEBUG |
107 bool ParseInfo::script_is_native() const { | 109 bool ParseInfo::script_is_native() const { |
108 return script_->type() == Script::TYPE_NATIVE; | 110 return script_->type() == Script::TYPE_NATIVE; |
109 } | 111 } |
110 #endif // DEBUG | 112 #endif // DEBUG |
111 | 113 |
112 } // namespace internal | 114 } // namespace internal |
113 } // namespace v8 | 115 } // namespace v8 |
OLD | NEW |