mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 22:02:51 +01:00
Migrate declaration parsing to value semantics (#614)
* Use Expression by value in FunctionDefinition * Migrate choice declarations to value semantics * Migrate Declaration parsing to value semantics
This commit is contained in:
@@ -314,9 +314,9 @@ void InitGlobals(std::list<Declaration>* fs) {
|
||||
|
||||
auto ChoiceDeclaration::InitGlobals(Env& globals) const -> void {
|
||||
auto alts = new VarValues();
|
||||
for (auto kv : alternatives) {
|
||||
auto t = InterpExp(Env(), kv.second);
|
||||
alts->push_back(make_pair(kv.first, t));
|
||||
for (const auto& [name, signature] : alternatives) {
|
||||
auto t = InterpExp(Env(), &signature);
|
||||
alts->push_back(make_pair(name, t));
|
||||
}
|
||||
auto ct = Value::MakeChoiceTypeVal(name, alts);
|
||||
auto a = state->heap.AllocateValue(ct);
|
||||
@@ -342,10 +342,10 @@ auto StructDeclaration::InitGlobals(Env& globals) const -> void {
|
||||
}
|
||||
|
||||
auto FunctionDeclaration::InitGlobals(Env& globals) const -> void {
|
||||
auto pt = InterpExp(globals, definition->param_pattern);
|
||||
auto f = Value::MakeFunVal(definition->name, pt, definition->body);
|
||||
auto pt = InterpExp(globals, &definition.param_pattern);
|
||||
auto f = Value::MakeFunVal(definition.name, pt, definition.body);
|
||||
Address a = state->heap.AllocateValue(f);
|
||||
globals.Set(definition->name, a);
|
||||
globals.Set(definition.name, a);
|
||||
}
|
||||
|
||||
// Adds an entry in `globals` mapping the variable's name to the
|
||||
|
||||
Reference in New Issue
Block a user