mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Consistent naming for Expression and Value. (#621)
- `Kind` enumerator names always match the corresponding factory function, accessor, and type names (if any). - All abbreviations in those names are expanded. - Those names always have a suffix to disambiguate expressions from values. `VarTV` is excluded from these changes because there's a pending PR to remove it.
This commit is contained in:
@@ -12,43 +12,43 @@
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
int Value::GetInteger() const {
|
||||
CHECK(tag == ValKind::IntV);
|
||||
int Value::GetIntValue() const {
|
||||
CHECK(tag == ValKind::IntValue);
|
||||
return u.integer;
|
||||
}
|
||||
|
||||
bool Value::GetBoolean() const {
|
||||
CHECK(tag == ValKind::BoolV);
|
||||
bool Value::GetBoolValue() const {
|
||||
CHECK(tag == ValKind::BoolValue);
|
||||
return u.boolean;
|
||||
}
|
||||
|
||||
Function Value::GetFunction() const {
|
||||
CHECK(tag == ValKind::FunV);
|
||||
FunctionValue Value::GetFunctionValue() const {
|
||||
CHECK(tag == ValKind::FunctionValue);
|
||||
return u.fun;
|
||||
}
|
||||
|
||||
StructConstructor Value::GetStruct() const {
|
||||
CHECK(tag == ValKind::StructV);
|
||||
StructValue Value::GetStructValue() const {
|
||||
CHECK(tag == ValKind::StructValue);
|
||||
return u.struct_val;
|
||||
}
|
||||
|
||||
AlternativeConstructor Value::GetAlternativeConstructor() const {
|
||||
CHECK(tag == ValKind::AltConsV);
|
||||
AlternativeConstructorValue Value::GetAlternativeConstructorValue() const {
|
||||
CHECK(tag == ValKind::AlternativeConstructorValue);
|
||||
return u.alt_cons;
|
||||
}
|
||||
|
||||
Alternative Value::GetAlternative() const {
|
||||
CHECK(tag == ValKind::AltV);
|
||||
AlternativeValue Value::GetAlternativeValue() const {
|
||||
CHECK(tag == ValKind::AlternativeValue);
|
||||
return u.alt;
|
||||
}
|
||||
|
||||
TupleValue Value::GetTuple() const {
|
||||
CHECK(tag == ValKind::TupleV);
|
||||
TupleValue Value::GetTupleValue() const {
|
||||
CHECK(tag == ValKind::TupleValue);
|
||||
return u.tuple;
|
||||
}
|
||||
|
||||
Address Value::GetPointer() const {
|
||||
CHECK(tag == ValKind::PtrV);
|
||||
Address Value::GetPointerValue() const {
|
||||
CHECK(tag == ValKind::PointerValue);
|
||||
return u.ptr;
|
||||
}
|
||||
|
||||
@@ -57,33 +57,33 @@ std::string* Value::GetVariableType() const {
|
||||
return u.var_type;
|
||||
}
|
||||
|
||||
VariablePatternValue Value::GetVariablePattern() const {
|
||||
CHECK(tag == ValKind::VarPatV);
|
||||
PatternVariableValue Value::GetPatternVariableValue() const {
|
||||
CHECK(tag == ValKind::PatternVariableValue);
|
||||
return u.var_pat;
|
||||
}
|
||||
|
||||
FunctionTypeValue Value::GetFunctionType() const {
|
||||
CHECK(tag == ValKind::FunctionTV);
|
||||
FunctionType Value::GetFunctionType() const {
|
||||
CHECK(tag == ValKind::FunctionType);
|
||||
return u.fun_type;
|
||||
}
|
||||
|
||||
PointerType Value::GetPointerType() const {
|
||||
CHECK(tag == ValKind::PointerTV);
|
||||
CHECK(tag == ValKind::PointerType);
|
||||
return u.ptr_type;
|
||||
}
|
||||
|
||||
StructType Value::GetStructType() const {
|
||||
CHECK(tag == ValKind::StructTV);
|
||||
CHECK(tag == ValKind::StructType);
|
||||
return u.struct_type;
|
||||
}
|
||||
|
||||
ChoiceType Value::GetChoiceType() const {
|
||||
CHECK(tag == ValKind::ChoiceTV);
|
||||
CHECK(tag == ValKind::ChoiceType);
|
||||
return u.choice_type;
|
||||
}
|
||||
|
||||
ContinuationValue Value::GetContinuation() const {
|
||||
CHECK(tag == ValKind::ContinuationV);
|
||||
ContinuationValue Value::GetContinuationValue() const {
|
||||
CHECK(tag == ValKind::ContinuationValue);
|
||||
return u.continuation;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ auto FieldsEqual(VarValues* ts1, VarValues* ts2) -> bool {
|
||||
|
||||
auto FindTupleField(const std::string& name, const Value* tuple)
|
||||
-> std::optional<Address> {
|
||||
CHECK(tuple->tag == ValKind::TupleV);
|
||||
for (const TupleElement& element : *tuple->GetTuple().elements) {
|
||||
CHECK(tuple->tag == ValKind::TupleValue);
|
||||
for (const TupleElement& element : *tuple->GetTupleValue().elements) {
|
||||
if (element.name == name) {
|
||||
return element.address;
|
||||
}
|
||||
@@ -125,67 +125,69 @@ auto FindTupleField(const std::string& name, const Value* tuple)
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto Value::MakeIntVal(int i) -> const Value* {
|
||||
auto Value::MakeIntValue(int i) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::IntV;
|
||||
v->tag = ValKind::IntValue;
|
||||
v->u.integer = i;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeBoolVal(bool b) -> const Value* {
|
||||
auto Value::MakeBoolValue(bool b) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::BoolV;
|
||||
v->tag = ValKind::BoolValue;
|
||||
v->u.boolean = b;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeFunVal(std::string name, const Value* param,
|
||||
const Statement* body) -> const Value* {
|
||||
auto Value::MakeFunctionValue(std::string name, const Value* param,
|
||||
const Statement* body) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::FunV;
|
||||
v->tag = ValKind::FunctionValue;
|
||||
v->u.fun.name = new std::string(std::move(name));
|
||||
v->u.fun.param = param;
|
||||
v->u.fun.body = body;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakePtrVal(Address addr) -> const Value* {
|
||||
auto Value::MakePointerValue(Address addr) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::PtrV;
|
||||
v->tag = ValKind::PointerValue;
|
||||
v->u.ptr = addr;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeStructVal(const Value* type, const Value* inits)
|
||||
auto Value::MakeStructValue(const Value* type, const Value* inits)
|
||||
-> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::StructV;
|
||||
v->tag = ValKind::StructValue;
|
||||
v->u.struct_val.type = type;
|
||||
v->u.struct_val.inits = inits;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeTupleVal(std::vector<TupleElement>* elements) -> const Value* {
|
||||
auto Value::MakeTupleValue(std::vector<TupleElement>* elements)
|
||||
-> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::TupleV;
|
||||
v->tag = ValKind::TupleValue;
|
||||
v->u.tuple.elements = elements;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeAltVal(std::string alt_name, std::string choice_name,
|
||||
Address argument) -> const Value* {
|
||||
auto Value::MakeAlternativeValue(std::string alt_name, std::string choice_name,
|
||||
Address argument) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::AltV;
|
||||
v->tag = ValKind::AlternativeValue;
|
||||
v->u.alt.alt_name = new std::string(std::move(alt_name));
|
||||
v->u.alt.choice_name = new std::string(std::move(choice_name));
|
||||
v->u.alt.argument = argument;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeAltCons(std::string alt_name, std::string choice_name)
|
||||
auto Value::MakeAlternativeConstructorValue(std::string alt_name,
|
||||
std::string choice_name)
|
||||
-> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::AltConsV;
|
||||
v->tag = ValKind::AlternativeConstructorValue;
|
||||
v->u.alt.alt_name = new std::string(std::move(alt_name));
|
||||
v->u.alt.choice_name = new std::string(std::move(choice_name));
|
||||
return v;
|
||||
@@ -193,16 +195,17 @@ auto Value::MakeAltCons(std::string alt_name, std::string choice_name)
|
||||
|
||||
// Return a first-class continuation represented a fragment
|
||||
// of the stack.
|
||||
auto Value::MakeContinuation(std::vector<Frame*> stack) -> Value* {
|
||||
auto Value::MakeContinuationValue(std::vector<Frame*> stack) -> Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::ContinuationV;
|
||||
v->tag = ValKind::ContinuationValue;
|
||||
v->u.continuation.stack = new std::vector<Frame*>(stack);
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeVarPatVal(std::string name, const Value* type) -> const Value* {
|
||||
auto Value::MakePatternVariableValue(std::string name, const Value* type)
|
||||
-> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::VarPatV;
|
||||
v->tag = ValKind::PatternVariableValue;
|
||||
v->u.var_pat.name = new std::string(std::move(name));
|
||||
v->u.var_pat.type = type;
|
||||
return v;
|
||||
@@ -215,57 +218,57 @@ auto Value::MakeVarTypeVal(std::string name) -> const Value* {
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeIntTypeVal() -> const Value* {
|
||||
auto Value::MakeIntType() -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::IntTV;
|
||||
v->tag = ValKind::IntType;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeBoolTypeVal() -> const Value* {
|
||||
auto Value::MakeBoolType() -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::BoolTV;
|
||||
v->tag = ValKind::BoolType;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeTypeTypeVal() -> const Value* {
|
||||
auto Value::MakeTypeType() -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::TypeTV;
|
||||
v->tag = ValKind::TypeType;
|
||||
return v;
|
||||
}
|
||||
|
||||
// Return a Continuation type.
|
||||
auto Value::MakeContinuationTypeVal() -> const Value* {
|
||||
auto Value::MakeContinuationType() -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::ContinuationTV;
|
||||
v->tag = ValKind::ContinuationType;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeAutoTypeVal() -> const Value* {
|
||||
auto Value::MakeAutoType() -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::AutoTV;
|
||||
v->tag = ValKind::AutoType;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeFunTypeVal(const Value* param, const Value* ret)
|
||||
auto Value::MakeFunctionType(const Value* param, const Value* ret)
|
||||
-> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::FunctionTV;
|
||||
v->tag = ValKind::FunctionType;
|
||||
v->u.fun_type.param = param;
|
||||
v->u.fun_type.ret = ret;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakePtrTypeVal(const Value* type) -> const Value* {
|
||||
auto Value::MakePointerType(const Value* type) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::PointerTV;
|
||||
v->tag = ValKind::PointerType;
|
||||
v->u.ptr_type.type = type;
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeStructTypeVal(std::string name, VarValues* fields,
|
||||
VarValues* methods) -> const Value* {
|
||||
auto Value::MakeStructType(std::string name, VarValues* fields,
|
||||
VarValues* methods) -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::StructTV;
|
||||
v->tag = ValKind::StructType;
|
||||
v->u.struct_type.name = new std::string(std::move(name));
|
||||
v->u.struct_type.fields = fields;
|
||||
v->u.struct_type.methods = methods;
|
||||
@@ -274,16 +277,16 @@ auto Value::MakeStructTypeVal(std::string name, VarValues* fields,
|
||||
|
||||
auto Value::MakeUnitTypeVal() -> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::TupleV;
|
||||
v->tag = ValKind::TupleValue;
|
||||
v->u.tuple.elements = new std::vector<TupleElement>();
|
||||
return v;
|
||||
}
|
||||
|
||||
auto Value::MakeChoiceTypeVal(
|
||||
auto Value::MakeChoiceType(
|
||||
std::string name, std::list<std::pair<std::string, const Value*>>* alts)
|
||||
-> const Value* {
|
||||
auto* v = new Value();
|
||||
v->tag = ValKind::ChoiceTV;
|
||||
v->tag = ValKind::ChoiceType;
|
||||
// Transitional leak: when we get rid of all pointers, this will disappear.
|
||||
v->u.choice_type.name = new std::string(name);
|
||||
v->u.choice_type.alternatives = alts;
|
||||
@@ -292,31 +295,31 @@ auto Value::MakeChoiceTypeVal(
|
||||
|
||||
auto PrintValue(const Value* val, std::ostream& out) -> void {
|
||||
switch (val->tag) {
|
||||
case ValKind::AltConsV: {
|
||||
out << *val->GetAlternativeConstructor().choice_name << "."
|
||||
<< *val->GetAlternativeConstructor().alt_name;
|
||||
case ValKind::AlternativeConstructorValue: {
|
||||
out << *val->GetAlternativeConstructorValue().choice_name << "."
|
||||
<< *val->GetAlternativeConstructorValue().alt_name;
|
||||
break;
|
||||
}
|
||||
case ValKind::VarPatV: {
|
||||
PrintValue(val->GetVariablePattern().type, out);
|
||||
out << ": " << *val->GetVariablePattern().name;
|
||||
case ValKind::PatternVariableValue: {
|
||||
PrintValue(val->GetPatternVariableValue().type, out);
|
||||
out << ": " << *val->GetPatternVariableValue().name;
|
||||
break;
|
||||
}
|
||||
case ValKind::AltV: {
|
||||
out << "alt " << *val->GetAlternative().choice_name << "."
|
||||
<< *val->GetAlternative().alt_name << " ";
|
||||
state->heap.PrintAddress(val->GetAlternative().argument, out);
|
||||
case ValKind::AlternativeValue: {
|
||||
out << "alt " << *val->GetAlternativeValue().choice_name << "."
|
||||
<< *val->GetAlternativeValue().alt_name << " ";
|
||||
state->heap.PrintAddress(val->GetAlternativeValue().argument, out);
|
||||
break;
|
||||
}
|
||||
case ValKind::StructV: {
|
||||
out << *val->GetStruct().type->GetStructType().name;
|
||||
PrintValue(val->GetStruct().inits, out);
|
||||
case ValKind::StructValue: {
|
||||
out << *val->GetStructValue().type->GetStructType().name;
|
||||
PrintValue(val->GetStructValue().inits, out);
|
||||
break;
|
||||
}
|
||||
case ValKind::TupleV: {
|
||||
case ValKind::TupleValue: {
|
||||
out << "(";
|
||||
bool add_commas = false;
|
||||
for (const TupleElement& element : *val->GetTuple().elements) {
|
||||
for (const TupleElement& element : *val->GetTupleValue().elements) {
|
||||
if (add_commas) {
|
||||
out << ", ";
|
||||
} else {
|
||||
@@ -329,38 +332,38 @@ auto PrintValue(const Value* val, std::ostream& out) -> void {
|
||||
out << ")";
|
||||
break;
|
||||
}
|
||||
case ValKind::IntV:
|
||||
out << val->GetInteger();
|
||||
case ValKind::IntValue:
|
||||
out << val->GetIntValue();
|
||||
break;
|
||||
case ValKind::BoolV:
|
||||
out << std::boolalpha << val->GetBoolean();
|
||||
case ValKind::BoolValue:
|
||||
out << std::boolalpha << val->GetBoolValue();
|
||||
break;
|
||||
case ValKind::FunV:
|
||||
out << "fun<" << *val->GetFunction().name << ">";
|
||||
case ValKind::FunctionValue:
|
||||
out << "fun<" << *val->GetFunctionValue().name << ">";
|
||||
break;
|
||||
case ValKind::PtrV:
|
||||
out << "ptr<" << val->GetPointer() << ">";
|
||||
case ValKind::PointerValue:
|
||||
out << "ptr<" << val->GetPointerValue() << ">";
|
||||
break;
|
||||
case ValKind::BoolTV:
|
||||
case ValKind::BoolType:
|
||||
out << "Bool";
|
||||
break;
|
||||
case ValKind::IntTV:
|
||||
case ValKind::IntType:
|
||||
out << "Int";
|
||||
break;
|
||||
case ValKind::TypeTV:
|
||||
case ValKind::TypeType:
|
||||
out << "Type";
|
||||
break;
|
||||
case ValKind::AutoTV:
|
||||
case ValKind::AutoType:
|
||||
out << "auto";
|
||||
break;
|
||||
case ValKind::ContinuationTV:
|
||||
case ValKind::ContinuationType:
|
||||
out << "Continuation";
|
||||
break;
|
||||
case ValKind::PointerTV:
|
||||
case ValKind::PointerType:
|
||||
PrintValue(val->GetPointerType().type, out);
|
||||
out << "*";
|
||||
break;
|
||||
case ValKind::FunctionTV:
|
||||
case ValKind::FunctionType:
|
||||
out << "fn ";
|
||||
PrintValue(val->GetFunctionType().param, out);
|
||||
out << " -> ";
|
||||
@@ -369,15 +372,15 @@ auto PrintValue(const Value* val, std::ostream& out) -> void {
|
||||
case ValKind::VarTV:
|
||||
out << *val->GetVariableType();
|
||||
break;
|
||||
case ValKind::StructTV:
|
||||
case ValKind::StructType:
|
||||
out << "struct " << *val->GetStructType().name;
|
||||
break;
|
||||
case ValKind::ChoiceTV:
|
||||
case ValKind::ChoiceType:
|
||||
out << "choice " << *val->GetChoiceType().name;
|
||||
break;
|
||||
case ValKind::ContinuationV:
|
||||
case ValKind::ContinuationValue:
|
||||
out << "continuation[[";
|
||||
for (Frame* frame : *val->GetContinuation().stack) {
|
||||
for (Frame* frame : *val->GetContinuationValue().stack) {
|
||||
PrintFrame(frame, out);
|
||||
out << " :: ";
|
||||
}
|
||||
@@ -393,37 +396,39 @@ auto TypeEqual(const Value* t1, const Value* t2) -> bool {
|
||||
switch (t1->tag) {
|
||||
case ValKind::VarTV:
|
||||
return *t1->GetVariableType() == *t2->GetVariableType();
|
||||
case ValKind::PointerTV:
|
||||
case ValKind::PointerType:
|
||||
return TypeEqual(t1->GetPointerType().type, t2->GetPointerType().type);
|
||||
case ValKind::FunctionTV:
|
||||
case ValKind::FunctionType:
|
||||
return TypeEqual(t1->GetFunctionType().param,
|
||||
t2->GetFunctionType().param) &&
|
||||
TypeEqual(t1->GetFunctionType().ret, t2->GetFunctionType().ret);
|
||||
case ValKind::StructTV:
|
||||
case ValKind::StructType:
|
||||
return *t1->GetStructType().name == *t2->GetStructType().name;
|
||||
case ValKind::ChoiceTV:
|
||||
case ValKind::ChoiceType:
|
||||
return *t1->GetChoiceType().name == *t2->GetChoiceType().name;
|
||||
case ValKind::TupleV: {
|
||||
if (t1->GetTuple().elements->size() != t2->GetTuple().elements->size()) {
|
||||
case ValKind::TupleValue: {
|
||||
if (t1->GetTupleValue().elements->size() !=
|
||||
t2->GetTupleValue().elements->size()) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < t1->GetTuple().elements->size(); ++i) {
|
||||
if ((*t1->GetTuple().elements)[i].name !=
|
||||
(*t2->GetTuple().elements)[i].name) {
|
||||
for (size_t i = 0; i < t1->GetTupleValue().elements->size(); ++i) {
|
||||
if ((*t1->GetTupleValue().elements)[i].name !=
|
||||
(*t2->GetTupleValue().elements)[i].name) {
|
||||
return false;
|
||||
}
|
||||
if (!TypeEqual(
|
||||
state->heap.Read((*t1->GetTuple().elements)[i].address, 0),
|
||||
state->heap.Read((*t2->GetTuple().elements)[i].address, 0))) {
|
||||
state->heap.Read((*t1->GetTupleValue().elements)[i].address, 0),
|
||||
state->heap.Read((*t2->GetTupleValue().elements)[i].address,
|
||||
0))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case ValKind::IntTV:
|
||||
case ValKind::BoolTV:
|
||||
case ValKind::ContinuationTV:
|
||||
case ValKind::TypeTV:
|
||||
case ValKind::IntType:
|
||||
case ValKind::BoolType:
|
||||
case ValKind::ContinuationType:
|
||||
case ValKind::TypeType:
|
||||
return true;
|
||||
default:
|
||||
std::cerr << "TypeEqual used to compare non-type values" << std::endl;
|
||||
@@ -465,34 +470,34 @@ auto ValueEqual(const Value* v1, const Value* v2, int line_num) -> bool {
|
||||
return false;
|
||||
}
|
||||
switch (v1->tag) {
|
||||
case ValKind::IntV:
|
||||
return v1->GetInteger() == v2->GetInteger();
|
||||
case ValKind::BoolV:
|
||||
return v1->GetBoolean() == v2->GetBoolean();
|
||||
case ValKind::PtrV:
|
||||
return v1->GetPointer() == v2->GetPointer();
|
||||
case ValKind::FunV:
|
||||
return v1->GetFunction().body == v2->GetFunction().body;
|
||||
case ValKind::TupleV:
|
||||
return FieldsValueEqual(v1->GetTuple().elements, v2->GetTuple().elements,
|
||||
line_num);
|
||||
case ValKind::IntValue:
|
||||
return v1->GetIntValue() == v2->GetIntValue();
|
||||
case ValKind::BoolValue:
|
||||
return v1->GetBoolValue() == v2->GetBoolValue();
|
||||
case ValKind::PointerValue:
|
||||
return v1->GetPointerValue() == v2->GetPointerValue();
|
||||
case ValKind::FunctionValue:
|
||||
return v1->GetFunctionValue().body == v2->GetFunctionValue().body;
|
||||
case ValKind::TupleValue:
|
||||
return FieldsValueEqual(v1->GetTupleValue().elements,
|
||||
v2->GetTupleValue().elements, line_num);
|
||||
default:
|
||||
case ValKind::VarTV:
|
||||
case ValKind::IntTV:
|
||||
case ValKind::BoolTV:
|
||||
case ValKind::TypeTV:
|
||||
case ValKind::FunctionTV:
|
||||
case ValKind::PointerTV:
|
||||
case ValKind::AutoTV:
|
||||
case ValKind::StructTV:
|
||||
case ValKind::ChoiceTV:
|
||||
case ValKind::ContinuationTV:
|
||||
case ValKind::IntType:
|
||||
case ValKind::BoolType:
|
||||
case ValKind::TypeType:
|
||||
case ValKind::FunctionType:
|
||||
case ValKind::PointerType:
|
||||
case ValKind::AutoType:
|
||||
case ValKind::StructType:
|
||||
case ValKind::ChoiceType:
|
||||
case ValKind::ContinuationType:
|
||||
return TypeEqual(v1, v2);
|
||||
case ValKind::StructV:
|
||||
case ValKind::AltV:
|
||||
case ValKind::VarPatV:
|
||||
case ValKind::AltConsV:
|
||||
case ValKind::ContinuationV:
|
||||
case ValKind::StructValue:
|
||||
case ValKind::AlternativeValue:
|
||||
case ValKind::PatternVariableValue:
|
||||
case ValKind::AlternativeConstructorValue:
|
||||
case ValKind::ContinuationValue:
|
||||
std::cerr << "ValueEqual does not support this kind of value."
|
||||
<< std::endl;
|
||||
exit(-1);
|
||||
@@ -501,8 +506,8 @@ auto ValueEqual(const Value* v1, const Value* v2, int line_num) -> bool {
|
||||
|
||||
auto ToInteger(const Value* v) -> int {
|
||||
switch (v->tag) {
|
||||
case ValKind::IntV:
|
||||
return v->GetInteger();
|
||||
case ValKind::IntValue:
|
||||
return v->GetIntValue();
|
||||
default:
|
||||
std::cerr << "expected an integer, not ";
|
||||
PrintValue(v, std::cerr);
|
||||
|
||||
Reference in New Issue
Block a user