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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 uintptr_t stack_limit() { return stack_limit_; } | 118 uintptr_t stack_limit() { return stack_limit_; } |
119 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } | 119 void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; } |
120 | 120 |
121 uint32_t hash_seed() { return hash_seed_; } | 121 uint32_t hash_seed() { return hash_seed_; } |
122 void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } | 122 void set_hash_seed(uint32_t hash_seed) { hash_seed_ = hash_seed; } |
123 | 123 |
124 //-------------------------------------------------------------------------- | 124 //-------------------------------------------------------------------------- |
125 // TODO(titzer): these should not be part of ParseInfo. | 125 // TODO(titzer): these should not be part of ParseInfo. |
126 //-------------------------------------------------------------------------- | 126 //-------------------------------------------------------------------------- |
127 Isolate* isolate() { return isolate_; } | 127 Isolate* isolate() { return isolate_; } |
128 Handle<JSFunction> closure() { return closure_; } | |
129 Handle<SharedFunctionInfo> shared_info() { return shared_; } | 128 Handle<SharedFunctionInfo> shared_info() { return shared_; } |
130 Handle<Script> script() { return script_; } | 129 Handle<Script> script() { return script_; } |
131 Handle<Context> context() { return context_; } | 130 Handle<Context> context() { return context_; } |
132 void clear_script() { script_ = Handle<Script>::null(); } | 131 void clear_script() { script_ = Handle<Script>::null(); } |
133 void set_isolate(Isolate* isolate) { isolate_ = isolate; } | 132 void set_isolate(Isolate* isolate) { isolate_ = isolate; } |
134 void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; } | 133 void set_shared_info(Handle<SharedFunctionInfo> shared) { shared_ = shared; } |
135 void set_context(Handle<Context> context) { context_ = context; } | 134 void set_context(Handle<Context> context) { context_ = context; } |
136 void set_script(Handle<Script> script) { script_ = script; } | 135 void set_script(Handle<Script> script) { script_ = script; } |
137 //-------------------------------------------------------------------------- | 136 //-------------------------------------------------------------------------- |
138 | 137 |
139 LanguageMode language_mode() { | 138 LanguageMode language_mode() { |
140 return construct_language_mode(is_strict_mode()); | 139 return construct_language_mode(is_strict_mode()); |
141 } | 140 } |
142 void set_language_mode(LanguageMode language_mode) { | 141 void set_language_mode(LanguageMode language_mode) { |
143 STATIC_ASSERT(LANGUAGE_END == 3); | 142 STATIC_ASSERT(LANGUAGE_END == 3); |
144 set_strict_mode(is_strict(language_mode)); | 143 set_strict_mode(is_strict(language_mode)); |
145 } | 144 } |
146 | 145 |
147 void ReopenHandlesInNewHandleScope() { | 146 void ReopenHandlesInNewHandleScope() { |
148 closure_ = Handle<JSFunction>(*closure_); | |
149 shared_ = Handle<SharedFunctionInfo>(*shared_); | 147 shared_ = Handle<SharedFunctionInfo>(*shared_); |
150 script_ = Handle<Script>(*script_); | 148 script_ = Handle<Script>(*script_); |
151 context_ = Handle<Context>(*context_); | 149 context_ = Handle<Context>(*context_); |
152 } | 150 } |
153 | 151 |
154 #ifdef DEBUG | 152 #ifdef DEBUG |
155 bool script_is_native() { return script_->type() == Script::TYPE_NATIVE; } | 153 bool script_is_native() { return script_->type() == Script::TYPE_NATIVE; } |
156 #endif // DEBUG | 154 #endif // DEBUG |
157 | 155 |
158 private: | 156 private: |
(...skipping 20 matching lines...) Expand all Loading... |
179 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; | 177 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; |
180 v8::Extension* extension_; | 178 v8::Extension* extension_; |
181 ScriptCompiler::CompileOptions compile_options_; | 179 ScriptCompiler::CompileOptions compile_options_; |
182 Scope* script_scope_; | 180 Scope* script_scope_; |
183 UnicodeCache* unicode_cache_; | 181 UnicodeCache* unicode_cache_; |
184 uintptr_t stack_limit_; | 182 uintptr_t stack_limit_; |
185 uint32_t hash_seed_; | 183 uint32_t hash_seed_; |
186 | 184 |
187 // TODO(titzer): Move handles and isolate out of ParseInfo. | 185 // TODO(titzer): Move handles and isolate out of ParseInfo. |
188 Isolate* isolate_; | 186 Isolate* isolate_; |
189 Handle<JSFunction> closure_; | |
190 Handle<SharedFunctionInfo> shared_; | 187 Handle<SharedFunctionInfo> shared_; |
191 Handle<Script> script_; | 188 Handle<Script> script_; |
192 Handle<Context> context_; | 189 Handle<Context> context_; |
193 | 190 |
194 //----------- Inputs+Outputs of parsing and scope analysis ----------------- | 191 //----------- Inputs+Outputs of parsing and scope analysis ----------------- |
195 ScriptData** cached_data_; // used if available, populated if requested. | 192 ScriptData** cached_data_; // used if available, populated if requested. |
196 AstValueFactory* ast_value_factory_; // used if available, otherwise new. | 193 AstValueFactory* ast_value_factory_; // used if available, otherwise new. |
197 | 194 |
198 //----------- Outputs of parsing and scope analysis ------------------------ | 195 //----------- Outputs of parsing and scope analysis ------------------------ |
199 FunctionLiteral* literal_; // produced by full parser. | 196 FunctionLiteral* literal_; // produced by full parser. |
200 Scope* scope_; // produced by scope analysis. | 197 Scope* scope_; // produced by scope analysis. |
201 | 198 |
202 void SetFlag(Flag f) { flags_ |= f; } | 199 void SetFlag(Flag f) { flags_ |= f; } |
203 void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; } | 200 void SetFlag(Flag f, bool v) { flags_ = v ? flags_ | f : flags_ & ~f; } |
204 bool GetFlag(Flag f) const { return (flags_ & f) != 0; } | 201 bool GetFlag(Flag f) const { return (flags_ & f) != 0; } |
205 | |
206 void set_closure(Handle<JSFunction> closure) { closure_ = closure; } | |
207 }; | 202 }; |
208 | 203 |
209 class FunctionEntry BASE_EMBEDDED { | 204 class FunctionEntry BASE_EMBEDDED { |
210 public: | 205 public: |
211 enum { | 206 enum { |
212 kStartPositionIndex, | 207 kStartPositionIndex, |
213 kEndPositionIndex, | 208 kEndPositionIndex, |
214 kLiteralCountIndex, | 209 kLiteralCountIndex, |
215 kPropertyCountIndex, | 210 kPropertyCountIndex, |
216 kLanguageModeIndex, | 211 kLanguageModeIndex, |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 | 1247 |
1253 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1248 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
1254 return parser_->ParseDoExpression(ok); | 1249 return parser_->ParseDoExpression(ok); |
1255 } | 1250 } |
1256 | 1251 |
1257 | 1252 |
1258 } // namespace internal | 1253 } // namespace internal |
1259 } // namespace v8 | 1254 } // namespace v8 |
1260 | 1255 |
1261 #endif // V8_PARSING_PARSER_H_ | 1256 #endif // V8_PARSING_PARSER_H_ |
OLD | NEW |