| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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) |
| 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(kStrongMode, is_strong_mode, set_strong_mode) | |
| 57 FLAG_ACCESSOR(kNative, is_native, set_native) | 56 FLAG_ACCESSOR(kNative, is_native, set_native) |
| 58 FLAG_ACCESSOR(kModule, is_module, set_module) | 57 FLAG_ACCESSOR(kModule, is_module, set_module) |
| 59 FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing) | 58 FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing) |
| 60 FLAG_ACCESSOR(kAstValueFactoryOwned, ast_value_factory_owned, | 59 FLAG_ACCESSOR(kAstValueFactoryOwned, ast_value_factory_owned, |
| 61 set_ast_value_factory_owned) | 60 set_ast_value_factory_owned) |
| 62 | 61 |
| 63 #undef FLAG_ACCESSOR | 62 #undef FLAG_ACCESSOR |
| 64 | 63 |
| 65 void set_parse_restriction(ParseRestriction restriction) { | 64 void set_parse_restriction(ParseRestriction restriction) { |
| 66 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION); | 65 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 Handle<SharedFunctionInfo> shared_info() { return shared_; } | 129 Handle<SharedFunctionInfo> shared_info() { return shared_; } |
| 131 Handle<Script> script() { return script_; } | 130 Handle<Script> script() { return script_; } |
| 132 Handle<Context> context() { return context_; } | 131 Handle<Context> context() { return context_; } |
| 133 void clear_script() { script_ = Handle<Script>::null(); } | 132 void clear_script() { script_ = Handle<Script>::null(); } |
| 134 void set_isolate(Isolate* isolate) { isolate_ = isolate; } | 133 void set_isolate(Isolate* isolate) { isolate_ = isolate; } |
| 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(), is_strong_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(language_mode & STRICT_BIT); | 143 set_strict_mode(is_strict(language_mode)); |
| 145 set_strong_mode(language_mode & STRONG_BIT); | |
| 146 } | 144 } |
| 147 | 145 |
| 148 void ReopenHandlesInNewHandleScope() { | 146 void ReopenHandlesInNewHandleScope() { |
| 149 closure_ = Handle<JSFunction>(*closure_); | 147 closure_ = Handle<JSFunction>(*closure_); |
| 150 shared_ = Handle<SharedFunctionInfo>(*shared_); | 148 shared_ = Handle<SharedFunctionInfo>(*shared_); |
| 151 script_ = Handle<Script>(*script_); | 149 script_ = Handle<Script>(*script_); |
| 152 context_ = Handle<Context>(*context_); | 150 context_ = Handle<Context>(*context_); |
| 153 } | 151 } |
| 154 | 152 |
| 155 #ifdef DEBUG | 153 #ifdef DEBUG |
| 156 bool script_is_native() { return script_->type() == Script::TYPE_NATIVE; } | 154 bool script_is_native() { return script_->type() == Script::TYPE_NATIVE; } |
| 157 #endif // DEBUG | 155 #endif // DEBUG |
| 158 | 156 |
| 159 private: | 157 private: |
| 160 // Various configuration flags for parsing. | 158 // Various configuration flags for parsing. |
| 161 enum Flag { | 159 enum Flag { |
| 162 // ---------- Input flags --------------------------- | 160 // ---------- Input flags --------------------------- |
| 163 kToplevel = 1 << 0, | 161 kToplevel = 1 << 0, |
| 164 kLazy = 1 << 1, | 162 kLazy = 1 << 1, |
| 165 kEval = 1 << 2, | 163 kEval = 1 << 2, |
| 166 kGlobal = 1 << 3, | 164 kGlobal = 1 << 3, |
| 167 kStrictMode = 1 << 4, | 165 kStrictMode = 1 << 4, |
| 168 kStrongMode = 1 << 5, | 166 kNative = 1 << 5, |
| 169 kNative = 1 << 6, | 167 kParseRestriction = 1 << 6, |
| 170 kParseRestriction = 1 << 7, | 168 kModule = 1 << 7, |
| 171 kModule = 1 << 8, | 169 kAllowLazyParsing = 1 << 8, |
| 172 kAllowLazyParsing = 1 << 9, | |
| 173 // ---------- Output flags -------------------------- | 170 // ---------- Output flags -------------------------- |
| 174 kAstValueFactoryOwned = 1 << 10 | 171 kAstValueFactoryOwned = 1 << 9 |
| 175 }; | 172 }; |
| 176 | 173 |
| 177 //------------- Inputs to parsing and scope analysis ----------------------- | 174 //------------- Inputs to parsing and scope analysis ----------------------- |
| 178 Zone* zone_; | 175 Zone* zone_; |
| 179 unsigned flags_; | 176 unsigned flags_; |
| 180 ScriptCompiler::ExternalSourceStream* source_stream_; | 177 ScriptCompiler::ExternalSourceStream* source_stream_; |
| 181 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; | 178 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; |
| 182 v8::Extension* extension_; | 179 v8::Extension* extension_; |
| 183 ScriptCompiler::CompileOptions compile_options_; | 180 ScriptCompiler::CompileOptions compile_options_; |
| 184 Scope* script_scope_; | 181 Scope* script_scope_; |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 | 1237 |
| 1241 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { | 1238 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { |
| 1242 return parser_->ParseDoExpression(ok); | 1239 return parser_->ParseDoExpression(ok); |
| 1243 } | 1240 } |
| 1244 | 1241 |
| 1245 | 1242 |
| 1246 } // namespace internal | 1243 } // namespace internal |
| 1247 } // namespace v8 | 1244 } // namespace v8 |
| 1248 | 1245 |
| 1249 #endif // V8_PARSING_PARSER_H_ | 1246 #endif // V8_PARSING_PARSER_H_ |
| OLD | NEW |