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

Side by Side Diff: src/preparser.h

Issue 8306024: Make native syntax an early error in the preparser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Unified enums Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/preparser.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 }; 111 };
112 112
113 ~PreParser() {} 113 ~PreParser() {}
114 114
115 // Pre-parse the program from the character stream; returns true on 115 // Pre-parse the program from the character stream; returns true on
116 // success (even if parsing failed, the pre-parse data successfully 116 // success (even if parsing failed, the pre-parse data successfully
117 // captured the syntax error), and false if a stack-overflow happened 117 // captured the syntax error), and false if a stack-overflow happened
118 // during parsing. 118 // during parsing.
119 static PreParseResult PreParseProgram(i::JavaScriptScanner* scanner, 119 static PreParseResult PreParseProgram(i::JavaScriptScanner* scanner,
120 i::ParserRecorder* log, 120 i::ParserRecorder* log,
121 bool allow_lazy, 121 int flags,
122 uintptr_t stack_limit) { 122 uintptr_t stack_limit) {
123 return PreParser(scanner, log, stack_limit, allow_lazy).PreParse(); 123 bool allow_lazy = (flags & i::kAllowLazy) != 0;
124 bool allow_natives_syntax = (flags & i::kAllowNativesSyntax) != 0;
125 return PreParser(scanner, log, stack_limit,
126 allow_lazy, allow_natives_syntax).PreParse();
124 } 127 }
125 128
126 private: 129 private:
127 // Used to detect duplicates in object literals. Each of the values 130 // Used to detect duplicates in object literals. Each of the values
128 // kGetterProperty, kSetterProperty and kValueProperty represents 131 // kGetterProperty, kSetterProperty and kValueProperty represents
129 // a type of object literal property. When parsing a property, its 132 // a type of object literal property. When parsing a property, its
130 // type value is stored in the DuplicateFinder for the property name. 133 // type value is stored in the DuplicateFinder for the property name.
131 // Values are chosen so that having intersection bits means the there is 134 // Values are chosen so that having intersection bits means the there is
132 // an incompatibility. 135 // an incompatibility.
133 // I.e., you can add a getter to a property that already has a setter, since 136 // I.e., you can add a getter to a property that already has a setter, since
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 int materialized_literal_count_; 433 int materialized_literal_count_;
431 int expected_properties_; 434 int expected_properties_;
432 int with_nesting_count_; 435 int with_nesting_count_;
433 bool strict_; 436 bool strict_;
434 }; 437 };
435 438
436 // Private constructor only used in PreParseProgram. 439 // Private constructor only used in PreParseProgram.
437 PreParser(i::JavaScriptScanner* scanner, 440 PreParser(i::JavaScriptScanner* scanner,
438 i::ParserRecorder* log, 441 i::ParserRecorder* log,
439 uintptr_t stack_limit, 442 uintptr_t stack_limit,
440 bool allow_lazy) 443 bool allow_lazy,
444 bool allow_natives_syntax)
441 : scanner_(scanner), 445 : scanner_(scanner),
442 log_(log), 446 log_(log),
443 scope_(NULL), 447 scope_(NULL),
444 stack_limit_(stack_limit), 448 stack_limit_(stack_limit),
445 strict_mode_violation_location_(i::Scanner::Location::invalid()), 449 strict_mode_violation_location_(i::Scanner::Location::invalid()),
446 strict_mode_violation_type_(NULL), 450 strict_mode_violation_type_(NULL),
447 stack_overflow_(false), 451 stack_overflow_(false),
448 allow_lazy_(true), 452 allow_lazy_(allow_lazy),
453 allow_natives_syntax_(allow_natives_syntax),
449 parenthesized_function_(false), 454 parenthesized_function_(false),
450 harmony_scoping_(scanner->HarmonyScoping()) { } 455 harmony_scoping_(scanner->HarmonyScoping()) { }
451 456
452 // Preparse the program. Only called in PreParseProgram after creating 457 // Preparse the program. Only called in PreParseProgram after creating
453 // the instance. 458 // the instance.
454 PreParseResult PreParse() { 459 PreParseResult PreParse() {
455 Scope top_scope(&scope_, kTopLevelScope); 460 Scope top_scope(&scope_, kTopLevelScope);
456 bool ok = true; 461 bool ok = true;
457 int start_position = scanner_->peek_location().beg_pos; 462 int start_position = scanner_->peek_location().beg_pos;
458 ParseSourceElements(i::Token::EOS, &ok); 463 ParseSourceElements(i::Token::EOS, &ok);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 bool* ok); 605 bool* ok);
601 606
602 i::JavaScriptScanner* scanner_; 607 i::JavaScriptScanner* scanner_;
603 i::ParserRecorder* log_; 608 i::ParserRecorder* log_;
604 Scope* scope_; 609 Scope* scope_;
605 uintptr_t stack_limit_; 610 uintptr_t stack_limit_;
606 i::Scanner::Location strict_mode_violation_location_; 611 i::Scanner::Location strict_mode_violation_location_;
607 const char* strict_mode_violation_type_; 612 const char* strict_mode_violation_type_;
608 bool stack_overflow_; 613 bool stack_overflow_;
609 bool allow_lazy_; 614 bool allow_lazy_;
615 bool allow_natives_syntax_;
610 bool parenthesized_function_; 616 bool parenthesized_function_;
611 bool harmony_scoping_; 617 bool harmony_scoping_;
612 }; 618 };
613 } } // v8::preparser 619 } } // v8::preparser
614 620
615 #endif // V8_PREPARSER_H 621 #endif // V8_PREPARSER_H
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698