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

Side by Side Diff: src/parser.h

Issue 1161393007: OLD type Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 5 years, 6 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/objects-inl.h ('k') | src/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_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 bool getter() const { return GetFlag(flag); } \ 46 bool getter() const { return GetFlag(flag); } \
47 void setter() { SetFlag(flag); } \ 47 void setter() { SetFlag(flag); } \
48 void setter(bool val) { SetFlag(flag, val); } 48 void setter(bool val) { SetFlag(flag, val); }
49 49
50 FLAG_ACCESSOR(kToplevel, is_toplevel, set_toplevel) 50 FLAG_ACCESSOR(kToplevel, is_toplevel, set_toplevel)
51 FLAG_ACCESSOR(kLazy, is_lazy, set_lazy) 51 FLAG_ACCESSOR(kLazy, is_lazy, set_lazy)
52 FLAG_ACCESSOR(kEval, is_eval, set_eval) 52 FLAG_ACCESSOR(kEval, is_eval, set_eval)
53 FLAG_ACCESSOR(kGlobal, is_global, set_global) 53 FLAG_ACCESSOR(kGlobal, is_global, set_global)
54 FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode) 54 FLAG_ACCESSOR(kStrictMode, is_strict_mode, set_strict_mode)
55 FLAG_ACCESSOR(kStrongMode, is_strong_mode, set_strong_mode) 55 FLAG_ACCESSOR(kStrongMode, is_strong_mode, set_strong_mode)
56 FLAG_ACCESSOR(kAsmFunction, is_asm_function, set_asm_function)
57 FLAG_ACCESSOR(kAsmModule, is_asm_module, set_asm_module)
56 FLAG_ACCESSOR(kNative, is_native, set_native) 58 FLAG_ACCESSOR(kNative, is_native, set_native)
57 FLAG_ACCESSOR(kModule, is_module, set_module) 59 FLAG_ACCESSOR(kModule, is_module, set_module)
58 FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing) 60 FLAG_ACCESSOR(kAllowLazyParsing, allow_lazy_parsing, set_allow_lazy_parsing)
59 FLAG_ACCESSOR(kAstValueFactoryOwned, ast_value_factory_owned, 61 FLAG_ACCESSOR(kAstValueFactoryOwned, ast_value_factory_owned,
60 set_ast_value_factory_owned) 62 set_ast_value_factory_owned)
61 63
62 #undef FLAG_ACCESSOR 64 #undef FLAG_ACCESSOR
63 65
64 void set_parse_restriction(ParseRestriction restriction) { 66 void set_parse_restriction(ParseRestriction restriction) {
65 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION); 67 SetFlag(kParseRestriction, restriction != NO_PARSE_RESTRICTION);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 142
141 LanguageMode language_mode() { 143 LanguageMode language_mode() {
142 return construct_language_mode(is_strict_mode(), is_strong_mode()); 144 return construct_language_mode(is_strict_mode(), is_strong_mode());
143 } 145 }
144 void set_language_mode(LanguageMode language_mode) { 146 void set_language_mode(LanguageMode language_mode) {
145 STATIC_ASSERT(LANGUAGE_END == 3); 147 STATIC_ASSERT(LANGUAGE_END == 3);
146 set_strict_mode(language_mode & STRICT_BIT); 148 set_strict_mode(language_mode & STRICT_BIT);
147 set_strong_mode(language_mode & STRONG_BIT); 149 set_strong_mode(language_mode & STRONG_BIT);
148 } 150 }
149 151
152 AsmMode asm_mode() {
153 return construct_asm_mode(is_asm_function(), is_asm_module());
154 }
155 void set_asm_mode(AsmMode asm_mode) {
156 STATIC_ASSERT(ASM_END == 3);
157 set_asm_function(asm_mode & ASM_FUNCTION_BIT);
158 set_asm_module(asm_mode & ASM_MODULE_BIT);
159 }
160
150 void ReopenHandlesInNewHandleScope() { 161 void ReopenHandlesInNewHandleScope() {
151 closure_ = Handle<JSFunction>(*closure_); 162 closure_ = Handle<JSFunction>(*closure_);
152 shared_ = Handle<SharedFunctionInfo>(*shared_); 163 shared_ = Handle<SharedFunctionInfo>(*shared_);
153 script_ = Handle<Script>(*script_); 164 script_ = Handle<Script>(*script_);
154 context_ = Handle<Context>(*context_); 165 context_ = Handle<Context>(*context_);
155 } 166 }
156 167
157 private: 168 private:
158 // Various configuration flags for parsing. 169 // Various configuration flags for parsing.
159 enum Flag { 170 enum Flag {
160 // ---------- Input flags --------------------------- 171 // ---------- Input flags ---------------------------
161 kToplevel = 1 << 0, 172 kToplevel = 1 << 0,
162 kLazy = 1 << 1, 173 kLazy = 1 << 1,
163 kEval = 1 << 2, 174 kEval = 1 << 2,
164 kGlobal = 1 << 3, 175 kGlobal = 1 << 3,
165 kStrictMode = 1 << 4, 176 kStrictMode = 1 << 4,
166 kStrongMode = 1 << 5, 177 kStrongMode = 1 << 5,
167 kNative = 1 << 6, 178 kNative = 1 << 6,
168 kParseRestriction = 1 << 7, 179 kParseRestriction = 1 << 7,
169 kModule = 1 << 8, 180 kModule = 1 << 8,
170 kAllowLazyParsing = 1 << 9, 181 kAllowLazyParsing = 1 << 9,
182 kAsmFunction = 1 << 10,
183 kAsmModule = 1 << 11,
171 // ---------- Output flags -------------------------- 184 // ---------- Output flags --------------------------
172 kAstValueFactoryOwned = 1 << 10 185 kAstValueFactoryOwned = 1 << 12
173 }; 186 };
174 187
175 //------------- Inputs to parsing and scope analysis ----------------------- 188 //------------- Inputs to parsing and scope analysis -----------------------
176 Zone* zone_; 189 Zone* zone_;
177 unsigned flags_; 190 unsigned flags_;
178 ScriptCompiler::ExternalSourceStream* source_stream_; 191 ScriptCompiler::ExternalSourceStream* source_stream_;
179 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_; 192 ScriptCompiler::StreamedSource::Encoding source_stream_encoding_;
180 v8::Extension* extension_; 193 v8::Extension* extension_;
181 ScriptCompiler::CompileOptions compile_options_; 194 ScriptCompiler::CompileOptions compile_options_;
182 Scope* script_scope_; 195 Scope* script_scope_;
(...skipping 25 matching lines...) Expand all
208 }; 221 };
209 222
210 class FunctionEntry BASE_EMBEDDED { 223 class FunctionEntry BASE_EMBEDDED {
211 public: 224 public:
212 enum { 225 enum {
213 kStartPositionIndex, 226 kStartPositionIndex,
214 kEndPositionIndex, 227 kEndPositionIndex,
215 kLiteralCountIndex, 228 kLiteralCountIndex,
216 kPropertyCountIndex, 229 kPropertyCountIndex,
217 kLanguageModeIndex, 230 kLanguageModeIndex,
231 kAsmModeIndex,
218 kUsesSuperPropertyIndex, 232 kUsesSuperPropertyIndex,
219 kCallsEvalIndex, 233 kCallsEvalIndex,
220 kSize 234 kSize
221 }; 235 };
222 236
223 explicit FunctionEntry(Vector<unsigned> backing) 237 explicit FunctionEntry(Vector<unsigned> backing)
224 : backing_(backing) { } 238 : backing_(backing) { }
225 239
226 FunctionEntry() : backing_() { } 240 FunctionEntry() : backing_() { }
227 241
228 int start_pos() { return backing_[kStartPositionIndex]; } 242 int start_pos() { return backing_[kStartPositionIndex]; }
229 int end_pos() { return backing_[kEndPositionIndex]; } 243 int end_pos() { return backing_[kEndPositionIndex]; }
230 int literal_count() { return backing_[kLiteralCountIndex]; } 244 int literal_count() { return backing_[kLiteralCountIndex]; }
231 int property_count() { return backing_[kPropertyCountIndex]; } 245 int property_count() { return backing_[kPropertyCountIndex]; }
232 LanguageMode language_mode() { 246 LanguageMode language_mode() {
233 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex])); 247 DCHECK(is_valid_language_mode(backing_[kLanguageModeIndex]));
234 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]); 248 return static_cast<LanguageMode>(backing_[kLanguageModeIndex]);
235 } 249 }
250
251 AsmMode asm_mode() {
252 DCHECK(backing_[kAsmModeIndex] == ASM_NO ||
253 backing_[kAsmModeIndex] == ASM_MODULE ||
254 backing_[kAsmModeIndex] == ASM_FUNCTION);
255 return static_cast<AsmMode>(backing_[kAsmModeIndex]);
256 }
257
236 bool uses_super_property() { return backing_[kUsesSuperPropertyIndex]; } 258 bool uses_super_property() { return backing_[kUsesSuperPropertyIndex]; }
237 bool calls_eval() { return backing_[kCallsEvalIndex]; } 259 bool calls_eval() { return backing_[kCallsEvalIndex]; }
238 260
239 bool is_valid() { return !backing_.is_empty(); } 261 bool is_valid() { return !backing_.is_empty(); }
240 262
241 private: 263 private:
242 Vector<unsigned> backing_; 264 Vector<unsigned> backing_;
243 }; 265 };
244 266
245 267
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 } 1298 }
1277 1299
1278 1300
1279 Expression* ParserTraits::SpreadCallNew( 1301 Expression* ParserTraits::SpreadCallNew(
1280 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1302 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1281 return parser_->SpreadCallNew(function, args, pos); 1303 return parser_->SpreadCallNew(function, args, pos);
1282 } 1304 }
1283 } } // namespace v8::internal 1305 } } // namespace v8::internal
1284 1306
1285 #endif // V8_PARSER_H_ 1307 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698