Replace all lists with vectors (#815)

This commit is contained in:
Geoff Romer
2021-09-07 09:20:10 -07:00
committed by GitHub
parent 225eda7f49
commit f931a8cead
13 changed files with 65 additions and 67 deletions
+2 -2
View File
@@ -5,7 +5,7 @@
#ifndef EXECUTABLE_SEMANTICS_AST_AST_H_
#define EXECUTABLE_SEMANTICS_AST_AST_H_
#include <list>
#include <vector>
#include "executable_semantics/ast/declaration.h"
#include "executable_semantics/ast/library_name.h"
@@ -22,7 +22,7 @@ struct AST {
// Import directives.
std::vector<LibraryName> imports;
// The file's ordered declarations.
std::list<Ptr<const Declaration>> declarations;
std::vector<Ptr<const Declaration>> declarations;
};
} // namespace Carbon
+2 -2
View File
@@ -5,8 +5,8 @@
#ifndef EXECUTABLE_SEMANTICS_AST_CLASS_DEFINITION_H_
#define EXECUTABLE_SEMANTICS_AST_CLASS_DEFINITION_H_
#include <list>
#include <string>
#include <vector>
#include "executable_semantics/ast/member.h"
#include "executable_semantics/ast/source_location.h"
@@ -16,7 +16,7 @@ namespace Carbon {
struct ClassDefinition {
SourceLocation loc;
std::string name;
std::list<Ptr<Member>> members;
std::vector<Ptr<Member>> members;
};
} // namespace Carbon
+5 -5
View File
@@ -5,8 +5,8 @@
#ifndef EXECUTABLE_SEMANTICS_AST_DECLARATION_H_
#define EXECUTABLE_SEMANTICS_AST_DECLARATION_H_
#include <list>
#include <string>
#include <vector>
#include "common/ostream.h"
#include "executable_semantics/ast/class_definition.h"
@@ -77,7 +77,7 @@ class FunctionDeclaration : public Declaration {
class ClassDeclaration : public Declaration {
public:
ClassDeclaration(SourceLocation loc, std::string name,
std::list<Ptr<Member>> members)
std::vector<Ptr<Member>> members)
: Declaration(Kind::ClassDeclaration, loc),
definition({.loc = loc,
.name = std::move(name),
@@ -97,7 +97,7 @@ class ChoiceDeclaration : public Declaration {
public:
ChoiceDeclaration(
SourceLocation loc, std::string name,
std::list<std::pair<std::string, Ptr<const Expression>>> alternatives)
std::vector<std::pair<std::string, Ptr<const Expression>>> alternatives)
: Declaration(Kind::ChoiceDeclaration, loc),
name(std::move(name)),
alternatives(std::move(alternatives)) {}
@@ -108,13 +108,13 @@ class ChoiceDeclaration : public Declaration {
auto Name() const -> const std::string& { return name; }
auto Alternatives() const
-> const std::list<std::pair<std::string, Ptr<const Expression>>>& {
-> const std::vector<std::pair<std::string, Ptr<const Expression>>>& {
return alternatives;
}
private:
std::string name;
std::list<std::pair<std::string, Ptr<const Expression>>> alternatives;
std::vector<std::pair<std::string, Ptr<const Expression>>> alternatives;
};
// Global variable definition implements the Declaration concept.
+7 -6
View File
@@ -5,7 +5,7 @@
#ifndef EXECUTABLE_SEMANTICS_AST_STATEMENT_H_
#define EXECUTABLE_SEMANTICS_AST_STATEMENT_H_
#include <list>
#include <vector>
#include "common/ostream.h"
#include "executable_semantics/ast/expression.h"
@@ -225,8 +225,9 @@ class Continue : public Statement {
class Match : public Statement {
public:
Match(SourceLocation loc, Ptr<const Expression> exp,
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>> clauses)
Match(
SourceLocation loc, Ptr<const Expression> exp,
std::vector<std::pair<Ptr<const Pattern>, Ptr<const Statement>>> clauses)
: Statement(Kind::Match, loc), exp(exp), clauses(std::move(clauses)) {}
static auto classof(const Statement* stmt) -> bool {
@@ -234,14 +235,14 @@ class Match : public Statement {
}
auto Exp() const -> Ptr<const Expression> { return exp; }
auto Clauses() const
-> const std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>& {
auto Clauses() const -> const
std::vector<std::pair<Ptr<const Pattern>, Ptr<const Statement>>>& {
return clauses;
}
private:
Ptr<const Expression> exp;
std::list<std::pair<Ptr<const Pattern>, Ptr<const Statement>>> clauses;
std::vector<std::pair<Ptr<const Pattern>, Ptr<const Statement>>> clauses;
};
// A continuation statement.