From 47c1870996405e1f27575f82ff033248b58126ce Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Tue, 16 Nov 2010 08:01:45 +0000 Subject: [PATCH] Move static scanner fields to scanner-base.h Review URL: http://codereview.chromium.org/5026005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5828 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/conversions.cc | 4 ++-- src/dateparser.h | 17 ++++++++++++--- src/heap.cc | 5 +++-- src/objects.cc | 8 ++++--- src/parser.cc | 19 ++++++++++++++--- src/scanner-base.cc | 27 ++++++++++++++++++++++++ src/scanner-base.h | 34 ++++++++++++++++++++++++------ src/scanner.cc | 56 +++++++++++++++---------------------------------- src/scanner.h | 8 ------- src/v8.cc | 1 + test/cctest/test-api.cc | 1 + 11 files changed, 114 insertions(+), 66 deletions(-) diff --git a/src/conversions.cc b/src/conversions.cc index 4cc6744..a1ec089 100644 --- a/src/conversions.cc +++ b/src/conversions.cc @@ -33,7 +33,7 @@ #include "conversions-inl.h" #include "dtoa.h" #include "factory.h" -#include "scanner.h" +#include "scanner-base.h" #include "strtod.h" namespace v8 { @@ -121,7 +121,7 @@ static const double JUNK_STRING_VALUE = OS::nan_value(); template static inline bool AdvanceToNonspace(Iterator* current, EndMark end) { while (*current != end) { - if (!Scanner::kIsWhiteSpace.get(**current)) return true; + if (!ScannerConstants::kIsWhiteSpace.get(**current)) return true; ++*current; } return false; diff --git a/src/dateparser.h b/src/dateparser.h index cae9b08..28053f4 100644 --- a/src/dateparser.h +++ b/src/dateparser.h @@ -28,7 +28,8 @@ #ifndef V8_DATEPARSER_H_ #define V8_DATEPARSER_H_ -#include "scanner.h" +#include "char-predicates-inl.h" +#include "scanner-base.h" namespace v8 { namespace internal { @@ -99,10 +100,20 @@ class DateParser : public AllStatic { } // The skip methods return whether they actually skipped something. - bool Skip(uint32_t c) { return ch_ == c ? (Next(), true) : false; } + bool Skip(uint32_t c) { + if (ch_ == c) { + Next(); + return true; + } + return false; + } bool SkipWhiteSpace() { - return Scanner::kIsWhiteSpace.get(ch_) ? (Next(), true) : false; + if (ScannerConstants::kIsWhiteSpace.get(ch_)) { + Next(); + return true; + } + return false; } bool SkipParentheses() { diff --git a/src/heap.cc b/src/heap.cc index 75ccc44..26859d7 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -38,7 +38,7 @@ #include "mark-compact.h" #include "natives.h" #include "objects-visiting.h" -#include "scanner.h" +#include "scanner-base.h" #include "scopeinfo.h" #include "snapshot.h" #include "v8threads.h" @@ -3249,7 +3249,8 @@ MaybeObject* Heap::AllocateStringFromUtf8(Vector string, const uc32 kMaxSupportedChar = 0xFFFF; // Count the number of characters in the UTF-8 string and check if // it is an ASCII string. - Access decoder(Scanner::utf8_decoder()); + Access + decoder(ScannerConstants::utf8_decoder()); decoder->Reset(string.start(), string.length()); int chars = 0; bool is_ascii = true; diff --git a/src/objects.cc b/src/objects.cc index c1cb922..8efb0da 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -35,7 +35,7 @@ #include "objects-inl.h" #include "objects-visiting.h" #include "macro-assembler.h" -#include "scanner.h" +#include "scanner-base.h" #include "scopeinfo.h" #include "string-stream.h" #include "utils.h" @@ -1208,7 +1208,8 @@ MaybeObject* JSObject::AddFastProperty(String* name, // Normalize the object if the name is an actual string (not the // hidden symbols) and is not a real identifier. StringInputBuffer buffer(name); - if (!Scanner::IsIdentifier(&buffer) && name != Heap::hidden_symbol()) { + if (!ScannerConstants::IsIdentifier(&buffer) + && name != Heap::hidden_symbol()) { Object* obj; { MaybeObject* maybe_obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); @@ -5088,7 +5089,8 @@ bool String::MarkAsUndetectable() { bool String::IsEqualTo(Vector str) { int slen = length(); - Access decoder(Scanner::utf8_decoder()); + Access + decoder(ScannerConstants::utf8_decoder()); decoder->Reset(str.start(), str.length()); int i; for (i = 0; i < slen && decoder->has_more(); i++) { diff --git a/src/parser.cc b/src/parser.cc index a0f3b71..e6a57e3 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -36,6 +36,7 @@ #include "messages.h" #include "parser.h" #include "platform.h" +#include "prescanner.h" #include "preparser.h" #include "runtime.h" #include "scopeinfo.h" @@ -4667,9 +4668,21 @@ ScriptDataImpl* ParserApi::PreParse(Handle source, unibrow::CharacterStream* stream, v8::Extension* extension) { Handle