mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 22:02:41 +01:00
[executable semantics] class-ify Declaration (#307)
* [executable semantics] class-ify Declaration NFC (no functional change). Proof of concept that we can simplify code by replacing unions with safer, more regular types. Hand-rolled existentials (type-erasing CoW wrappers) are a follow-on step that will further simplify usage. Began adding `const` where possible, and replacing `std::string*` with `std::string`. Most `const`s can disappear as we replace reference semantics with value semantics, but in the meantime it's an important step in the right direction.
This commit is contained in:
@@ -197,13 +197,14 @@ auto MakeVoidTypeVal() -> Value* {
|
||||
return v;
|
||||
}
|
||||
|
||||
auto MakeChoiceTypeVal(std::string* name,
|
||||
auto MakeChoiceTypeVal(std::string name,
|
||||
std::list<std::pair<std::string, Value*>>* alts)
|
||||
-> Value* {
|
||||
auto* v = new Value();
|
||||
v->alive = true;
|
||||
v->tag = ValKind::ChoiceTV;
|
||||
v->u.choice_type.name = name;
|
||||
// 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;
|
||||
return v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user