renames ExecutionEnvironment, fixes #394 (#395)

This commit is contained in:
Jeremy G. Siek
2021-03-18 22:19:31 -04:00
committed by GitHub
parent e440b07eb3
commit b2455d8dba
4 changed files with 40 additions and 38 deletions
+16 -16
View File
@@ -658,8 +658,8 @@ auto VariableDeclaration::TypeChecked(TypeEnv env, Env ct_env) const
return *this;
}
auto TopLevel(std::list<Declaration>* fs) -> std::pair<TypeEnv, Env> {
ExecutionEnvironment tops;
auto TopLevel(std::list<Declaration>* fs) -> TypeCheckContext {
TypeCheckContext tops;
bool found_main = false;
for (auto const& d : *fs) {
@@ -677,37 +677,37 @@ auto TopLevel(std::list<Declaration>* fs) -> std::pair<TypeEnv, Env> {
return tops;
}
auto FunctionDeclaration::TopLevel(ExecutionEnvironment& tops) const -> void {
auto t = TypeOfFunDef(tops.first, tops.second, definition);
tops.first.Set(Name(), t);
auto FunctionDeclaration::TopLevel(TypeCheckContext& tops) const -> void {
auto t = TypeOfFunDef(tops.types, tops.values, definition);
tops.types.Set(Name(), t);
}
auto StructDeclaration::TopLevel(ExecutionEnvironment& tops) const -> void {
auto st = TypeOfStructDef(&definition, tops.first, tops.second);
auto StructDeclaration::TopLevel(TypeCheckContext& tops) const -> void {
auto st = TypeOfStructDef(&definition, tops.types, tops.values);
Address a = AllocateValue(st);
tops.second.Set(Name(), a); // Is this obsolete?
tops.values.Set(Name(), a); // Is this obsolete?
auto params = MakeTupleTypeVal(st->u.struct_type.fields);
auto fun_ty = MakeFunTypeVal(params, st);
tops.first.Set(Name(), fun_ty);
tops.types.Set(Name(), fun_ty);
}
auto ChoiceDeclaration::TopLevel(ExecutionEnvironment& tops) const -> void {
auto ChoiceDeclaration::TopLevel(TypeCheckContext& tops) const -> void {
auto alts = new VarValues();
for (auto a : alternatives) {
auto t = ToType(line_num, InterpExp(tops.second, a.second));
auto t = ToType(line_num, InterpExp(tops.values, a.second));
alts->push_back(std::make_pair(a.first, t));
}
auto ct = MakeChoiceTypeVal(name, alts);
Address a = AllocateValue(ct);
tops.second.Set(Name(), a); // Is this obsolete?
tops.first.Set(Name(), ct);
tops.values.Set(Name(), a); // Is this obsolete?
tops.types.Set(Name(), ct);
}
// Associate the variable name with it's declared type in the
// compile-time symbol table.
auto VariableDeclaration::TopLevel(ExecutionEnvironment& tops) const -> void {
Value* declared_type = ToType(source_location, InterpExp(tops.second, type));
tops.first.Set(Name(), declared_type);
auto VariableDeclaration::TopLevel(TypeCheckContext& tops) const -> void {
Value* declared_type = ToType(source_location, InterpExp(tops.values, type));
tops.types.Set(Name(), declared_type);
}
} // namespace Carbon
+1 -1
View File
@@ -45,7 +45,7 @@ auto TypeCheckStmt(Statement*, TypeEnv, Env, Value*) -> TCStatement;
auto TypeCheckFunDef(struct FunctionDefinition*, TypeEnv)
-> struct FunctionDefinition*;
auto TopLevel(std::list<Declaration>* fs) -> std::pair<TypeEnv, Env>;
auto TopLevel(std::list<Declaration>* fs) -> TypeCheckContext;
void PrintErrorString(const std::string& s);