From 81a3f7bfb50bf76290ee48bb2342c5beda2d7618 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Wed, 27 Oct 2010 12:33:48 +0000 Subject: [PATCH] Make Parser class have no friends and fewer things to depend on it. Review URL: http://codereview.chromium.org/4146006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5719 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 4 +- src/compiler.cc | 6 +- src/jsregexp.cc | 6 +- src/liveedit.cc | 2 +- src/parser.cc | 340 +++++++++------------------------------------ src/parser.h | 247 ++++++++++++++++++++++++++++++-- test/cctest/test-regexp.cc | 13 +- 7 files changed, 317 insertions(+), 301 deletions(-) diff --git a/src/api.cc b/src/api.cc index 2df31df..617922d 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1155,13 +1155,13 @@ void ObjectTemplate::SetInternalFieldCount(int value) { ScriptData* ScriptData::PreCompile(const char* input, int length) { unibrow::Utf8InputBuffer<> buf(input, length); - return i::Parser::PreParse(i::Handle(), &buf, NULL); + return i::ParserApi::PreParse(i::Handle(), &buf, NULL); } ScriptData* ScriptData::PreCompile(v8::Handle source) { i::Handle str = Utils::OpenHandle(*source); - return i::Parser::PreParse(str, NULL, NULL); + return i::ParserApi::PreParse(str, NULL, NULL); } diff --git a/src/compiler.cc b/src/compiler.cc index 1674ca8..6f02960 100755 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -176,7 +176,7 @@ static Handle MakeFunctionInfo(CompilationInfo* info) { // Only allow non-global compiles for eval. ASSERT(info->is_eval() || info->is_global()); - if (!Parser::Parse(info)) return Handle::null(); + if (!ParserApi::Parse(info)) return Handle::null(); // Measure how long it takes to do the compilation; only take the // rest of the function into account to avoid overlap with the @@ -281,7 +281,7 @@ Handle Compiler::Compile(Handle source, if (pre_data == NULL && FLAG_lazy && source_length >= FLAG_min_preparse_length) { - pre_data = Parser::PartialPreParse(source, NULL, extension); + pre_data = ParserApi::PartialPreParse(source, NULL, extension); } // Create a script object describing the script to be compiled. @@ -364,7 +364,7 @@ bool Compiler::CompileLazy(CompilationInfo* info) { Counters::total_compile_size.Increment(compiled_size); // Generate the AST for the lazily compiled function. - if (Parser::Parse(info)) { + if (ParserApi::Parse(info)) { // Measure how long it takes to do the lazy compilation; only take the // rest of the function into account to avoid overlap with the lazy // parsing statistics. diff --git a/src/jsregexp.cc b/src/jsregexp.cc index 3c5ddfb..8cd13bc 100644 --- a/src/jsregexp.cc +++ b/src/jsregexp.cc @@ -125,7 +125,8 @@ Handle RegExpImpl::Compile(Handle re, PostponeInterruptsScope postpone; RegExpCompileData parse_result; FlatStringReader reader(pattern); - if (!Parser::ParseRegExp(&reader, flags.is_multiline(), &parse_result)) { + if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), + &parse_result)) { // Throw an exception if we fail to parse the pattern. ThrowRegExpException(re, pattern, @@ -267,7 +268,8 @@ bool RegExpImpl::CompileIrregexp(Handle re, bool is_ascii) { RegExpCompileData compile_data; FlatStringReader reader(pattern); - if (!Parser::ParseRegExp(&reader, flags.is_multiline(), &compile_data)) { + if (!RegExpParser::ParseRegExp(&reader, flags.is_multiline(), + &compile_data)) { // Throw an exception if we fail to parse the pattern. // THIS SHOULD NOT HAPPEN. We already pre-parsed it successfully once. ThrowRegExpException(re, diff --git a/src/liveedit.cc b/src/liveedit.cc index 49f221a..642b3e6 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -404,7 +404,7 @@ static void CompileScriptForTracker(Handle