[cleanup] Add an iterator to ZonePtrList and use it in some places
Bug: v8:8834 Change-Id: I1d7451a6306bc34e6254383fd79e8411bffd26ce Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1545894 Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Peter Marshall <petermarshall@chromium.org> Cr-Commit-Position: refs/heads/master@{#60600}
This commit is contained in:
parent
ac8c78e01d
commit
e3a0aca0b9
@ -54,9 +54,7 @@ void Reparenter::VisitClassLiteral(ClassLiteral* class_literal) {
|
||||
#if DEBUG
|
||||
// The same goes for the rest of the class, but we do some
|
||||
// sanity checking in debug mode.
|
||||
ZonePtrList<ClassLiteralProperty>* props = class_literal->properties();
|
||||
for (int i = 0; i < props->length(); ++i) {
|
||||
ClassLiteralProperty* prop = props->at(i);
|
||||
for (ClassLiteralProperty* prop : *class_literal->properties()) {
|
||||
// No need to visit the values, since all values are functions with
|
||||
// the class scope on their scope chain.
|
||||
DCHECK(prop->value()->IsFunctionLiteral());
|
||||
|
@ -459,8 +459,8 @@ class ExpressionParsingScope : public ExpressionScope<Types> {
|
||||
ExpressionScopeT::Report(Scanner::Location(begin, end),
|
||||
MessageTemplate::kInvalidDestructuringTarget);
|
||||
}
|
||||
for (int i = 0; i < variable_list_.length(); i++) {
|
||||
variable_list_.at(i)->set_is_assigned();
|
||||
for (VariableProxy* proxy : variable_list_) {
|
||||
proxy->set_is_assigned();
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,8 +666,8 @@ class ArrowHeadParsingScope : public ExpressionParsingScope<Types> {
|
||||
// references.
|
||||
this->parser()->next_arrow_function_info_.ClearStrictParameterError();
|
||||
ExpressionParsingScope<Types>::ValidateExpression();
|
||||
for (int i = 0; i < this->variable_list()->length(); i++) {
|
||||
this->parser()->scope()->AddUnresolved(this->variable_list()->at(i));
|
||||
for (VariableProxy* proxy : *this->variable_list()) {
|
||||
this->parser()->scope()->AddUnresolved(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -684,8 +684,7 @@ class ArrowHeadParsingScope : public ExpressionParsingScope<Types> {
|
||||
VariableKind kind = PARAMETER_VARIABLE;
|
||||
VariableMode mode =
|
||||
has_simple_parameter_list_ ? VariableMode::kVar : VariableMode::kLet;
|
||||
for (int i = 0; i < this->variable_list()->length(); i++) {
|
||||
VariableProxy* proxy = this->variable_list()->at(i);
|
||||
for (VariableProxy* proxy : *this->variable_list()) {
|
||||
bool was_added;
|
||||
this->parser()->DeclareAndBindVariable(
|
||||
proxy, kind, mode, Variable::DefaultInitializationFlag(mode), result,
|
||||
|
@ -1131,8 +1131,7 @@ void Parser::ParseImportDeclaration() {
|
||||
if (named_imports->length() == 0) {
|
||||
module()->AddEmptyImport(module_specifier, specifier_loc);
|
||||
} else {
|
||||
for (int i = 0; i < named_imports->length(); ++i) {
|
||||
const NamedImport* import = named_imports->at(i);
|
||||
for (const NamedImport* import : *named_imports) {
|
||||
module()->AddImport(import->import_name, import->local_name,
|
||||
module_specifier, import->location, specifier_loc,
|
||||
zone());
|
||||
@ -1351,8 +1350,8 @@ Statement* Parser::ParseExportDeclaration() {
|
||||
loc.end_pos = scanner()->location().end_pos;
|
||||
|
||||
ModuleDescriptor* descriptor = module();
|
||||
for (int i = 0; i < names.length(); ++i) {
|
||||
descriptor->AddExport(names[i], names[i], loc, zone());
|
||||
for (const AstRawString* name : names) {
|
||||
descriptor->AddExport(name, name, loc, zone());
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -1888,12 +1887,12 @@ Block* Parser::CreateForEachStatementTDZ(Block* init_block,
|
||||
|
||||
init_block = factory()->NewBlock(1, false);
|
||||
|
||||
for (int i = 0; i < for_info.bound_names.length(); ++i) {
|
||||
for (const AstRawString* bound_name : for_info.bound_names) {
|
||||
// TODO(adamk): This needs to be some sort of special
|
||||
// INTERNAL variable that's invisible to the debugger
|
||||
// but visible to everything else.
|
||||
VariableProxy* tdz_proxy = DeclareBoundVariable(
|
||||
for_info.bound_names[i], VariableMode::kLet, kNoSourcePosition);
|
||||
bound_name, VariableMode::kLet, kNoSourcePosition);
|
||||
tdz_proxy->var()->set_initializer_position(position());
|
||||
}
|
||||
}
|
||||
@ -1953,8 +1952,8 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
|
||||
|
||||
// For each lexical variable x:
|
||||
// make statement: temp_x = x.
|
||||
for (int i = 0; i < for_info.bound_names.length(); i++) {
|
||||
VariableProxy* proxy = NewUnresolved(for_info.bound_names[i]);
|
||||
for (const AstRawString* bound_name : for_info.bound_names) {
|
||||
VariableProxy* proxy = NewUnresolved(bound_name);
|
||||
Variable* temp = NewTemporary(temp_name);
|
||||
VariableProxy* temp_proxy = factory()->NewVariableProxy(temp);
|
||||
Assignment* assignment = factory()->NewAssignment(Token::ASSIGN, temp_proxy,
|
||||
@ -2697,15 +2696,14 @@ void Parser::ParseFunction(
|
||||
// For a function implicitly wrapped in function header and footer, the
|
||||
// function arguments are provided separately to the source, and are
|
||||
// declared directly here.
|
||||
int arguments_length = arguments_for_wrapped_function->length();
|
||||
for (int i = 0; i < arguments_length; i++) {
|
||||
for (const AstRawString* arg : *arguments_for_wrapped_function) {
|
||||
const bool is_rest = false;
|
||||
Expression* argument = ExpressionFromIdentifier(
|
||||
arguments_for_wrapped_function->at(i), kNoSourcePosition);
|
||||
Expression* argument = ExpressionFromIdentifier(arg, kNoSourcePosition);
|
||||
AddFormalParameter(&formals, argument, NullExpression(),
|
||||
kNoSourcePosition, is_rest);
|
||||
}
|
||||
DCHECK_EQ(arguments_length, formals.num_parameters());
|
||||
DCHECK_EQ(arguments_for_wrapped_function->length(),
|
||||
formals.num_parameters());
|
||||
DeclareFormalParameters(&formals);
|
||||
} else {
|
||||
// For a regular function, the function arguments are parsed from source.
|
||||
|
@ -431,7 +431,7 @@ bool BufferedUtf16CharacterStream::ReadBlock() {
|
||||
//
|
||||
// This implementation is fairly complex, since data arrives in chunks which
|
||||
// may 'cut' arbitrarily into utf-8 characters. Also, seeking to a given
|
||||
// character position is tricky because the byte position cannot be dericed
|
||||
// character position is tricky because the byte position cannot be derived
|
||||
// from the character position.
|
||||
//
|
||||
// TODO(verwaest): Decode utf8 chunks into utf16 chunks on the blink side
|
||||
@ -444,7 +444,7 @@ class Utf8ExternalStreamingStream : public BufferedUtf16CharacterStream {
|
||||
: current_({0, {0, 0, 0, unibrow::Utf8::State::kAccept}}),
|
||||
source_stream_(source_stream) {}
|
||||
~Utf8ExternalStreamingStream() final {
|
||||
for (size_t i = 0; i < chunks_.size(); i++) delete[] chunks_[i].data;
|
||||
for (const Chunk& chunk : chunks_) delete[] chunk.data;
|
||||
}
|
||||
|
||||
bool can_access_heap() const final { return false; }
|
||||
|
@ -388,6 +388,12 @@ class ScopedPtrList final {
|
||||
end_ += list.length();
|
||||
}
|
||||
|
||||
typedef T** iterator;
|
||||
inline iterator begin() const {
|
||||
return reinterpret_cast<T**>(&buffer_[start_]);
|
||||
}
|
||||
inline iterator end() const { return reinterpret_cast<T**>(&buffer_[end_]); }
|
||||
|
||||
private:
|
||||
std::vector<void*>& buffer_;
|
||||
size_t start_;
|
||||
|
Loading…
Reference in New Issue
Block a user