Switch FunctionDefinition to a class (#852)

Splitting out the task from #849
This commit is contained in:
Jon Meow
2021-09-27 09:05:04 -07:00
committed by GitHub
parent c9b5c2fa1a
commit 6ab2bff69c
5 changed files with 66 additions and 49 deletions
@@ -113,14 +113,14 @@ void Interpreter::InitEnv(const Declaration& d, Env* env) {
cast<FunctionDeclaration>(d).Definition();
Env new_env = *env;
// Bring the deduced parameters into scope.
for (const auto& deduced : func_def.deduced_parameters) {
for (const auto& deduced : func_def.deduced_parameters()) {
Address a = heap.AllocateValue(arena->New<VariableType>(deduced.name));
new_env.Set(deduced.name, a);
}
auto pt = InterpPattern(new_env, func_def.param_pattern);
auto f = arena->New<FunctionValue>(func_def.name, pt, func_def.body);
auto pt = InterpPattern(new_env, &func_def.param_pattern());
auto f = arena->New<FunctionValue>(func_def.name(), pt, func_def.body());
Address a = heap.AllocateValue(f);
env->Set(func_def.name, a);
env->Set(func_def.name(), a);
break;
}