mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:54:44 +01:00
Stop using std::pair in the implementation of tuples (#479)
This commit is contained in:
@@ -17,7 +17,6 @@ namespace Carbon {
|
||||
struct Value;
|
||||
using Address = unsigned int;
|
||||
using VarValues = std::list<std::pair<std::string, const Value*>>;
|
||||
using VarAddresses = std::vector<std::pair<std::string, Address>>;
|
||||
|
||||
auto FindInVarValues(const std::string& field, VarValues* inits)
|
||||
-> const Value*;
|
||||
@@ -28,6 +27,15 @@ auto FieldsEqual(VarValues* ts1, VarValues* ts2) -> bool;
|
||||
auto FindTupleField(const std::string& name, const Value* tuple)
|
||||
-> std::optional<Address>;
|
||||
|
||||
// A TupleElement represents the value of a single tuple field.
|
||||
struct TupleElement {
|
||||
// The field name.
|
||||
std::string name;
|
||||
|
||||
// Location of the field's value.
|
||||
Address address;
|
||||
};
|
||||
|
||||
enum class ValKind {
|
||||
IntV,
|
||||
FunV,
|
||||
@@ -82,7 +90,7 @@ struct Value {
|
||||
} alt;
|
||||
|
||||
struct {
|
||||
VarAddresses* elts;
|
||||
std::vector<TupleElement>* elements;
|
||||
} tuple;
|
||||
|
||||
Address ptr;
|
||||
@@ -134,8 +142,7 @@ auto MakeFunVal(std::string name, const Value* param, const Statement* body)
|
||||
-> const Value*;
|
||||
auto MakePtrVal(Address addr) -> const Value*;
|
||||
auto MakeStructVal(const Value* type, const Value* inits) -> const Value*;
|
||||
auto MakeTupleVal(std::vector<std::pair<std::string, Address>>* elts)
|
||||
-> const Value*;
|
||||
auto MakeTupleVal(std::vector<TupleElement>* elts) -> const Value*;
|
||||
auto MakeAltVal(std::string alt_name, std::string choice_name, Address argument)
|
||||
-> const Value*;
|
||||
auto MakeAltCons(std::string alt_name, std::string choice_name) -> const Value*;
|
||||
|
||||
Reference in New Issue
Block a user