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

Unified Diff: src/parser.cc

Issue 156423005: Move ParseRegexpLiteral to ParserBase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code review (ulan) Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 0f842ad8dadd975dc46e9a5282ddd85256baad15..24eaef0c3d34c51e45a11b17fcd121d5a0e9e84e 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -551,6 +551,11 @@ bool ParserTraits::IsEvalOrArguments(Handle<String> identifier) const {
}
+int ParserTraits::NextMaterializedLiteralIndex() {
+ return parser_->current_function_state_->NextMaterializedLiteralIndex();
+}
+
+
void ParserTraits::ReportMessageAt(Scanner::Location source_location,
const char* message,
Vector<const char*> args) {
@@ -601,6 +606,27 @@ Handle<String> ParserTraits::GetSymbol() {
return parser_->LookupSymbol(symbol_id);
}
+
+Handle<String> ParserTraits::NextLiteralString(PretenureFlag tenured) {
+ Scanner& scanner = parser_->scanner();
+ if (scanner.is_next_literal_ascii()) {
+ return parser_->isolate_->factory()->NewStringFromAscii(
+ scanner.next_literal_ascii_string(), tenured);
+ } else {
+ return parser_->isolate_->factory()->NewStringFromTwoByte(
+ scanner.next_literal_utf16_string(), tenured);
+ }
+}
+
+
+Expression* ParserTraits::NewRegExpLiteral(Handle<String> js_pattern,
+ Handle<String> js_flags,
+ int literal_index,
+ int pos) {
+ return parser_->factory()->NewRegExpLiteral(
+ js_pattern, js_flags, literal_index, pos);
+}
+
Parser::Parser(CompilationInfo* info)
: ParserBase<ParserTraits>(&scanner_,
info->isolate()->stack_guard()->real_climit(),
@@ -3834,26 +3860,6 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
}
-Expression* Parser::ParseRegExpLiteral(bool seen_equal, bool* ok) {
- int pos = peek_position();
- if (!scanner().ScanRegExpPattern(seen_equal)) {
- Next();
- ReportMessage("unterminated_regexp", Vector<const char*>::empty());
- *ok = false;
- return NULL;
- }
-
- int literal_index = current_function_state_->NextMaterializedLiteralIndex();
-
- Handle<String> js_pattern = NextLiteralString(TENURED);
- scanner().ScanRegExpFlags();
- Handle<String> js_flags = NextLiteralString(TENURED);
- Next();
-
- return factory()->NewRegExpLiteral(js_pattern, js_flags, literal_index, pos);
-}
-
-
ZoneList<Expression*>* Parser::ParseArguments(bool* ok) {
// Arguments ::
// '(' (AssignmentExpression)*[','] ')'
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698