No longer destroy the list of free variables.
It so happens that this list will tell us which variables need to be captured.
This commit is contained in:
parent
feeee2039b
commit
dec6d834f5
|
@ -114,15 +114,13 @@ void definition_group::find_free(type_mgr& mgr, type_env_ptr& env, std::set<std:
|
||||||
|
|
||||||
for(auto& def_pair : defs_defn) {
|
for(auto& def_pair : defs_defn) {
|
||||||
def_pair.second->find_free(mgr, env);
|
def_pair.second->find_free(mgr, env);
|
||||||
std::set<std::string> local_dependencies;
|
|
||||||
for(auto& free_var : def_pair.second->free_variables) {
|
for(auto& free_var : def_pair.second->free_variables) {
|
||||||
if(defs_defn.find(free_var) == defs_defn.end()) {
|
if(defs_defn.find(free_var) == defs_defn.end()) {
|
||||||
into.insert(free_var);
|
into.insert(free_var);
|
||||||
} else {
|
} else {
|
||||||
local_dependencies.insert(free_var);
|
def_pair.second->nearby_variables.insert(free_var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::swap(def_pair.second->free_variables, local_dependencies);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +138,7 @@ void definition_group::typecheck(type_mgr& mgr) {
|
||||||
def_defn.second->find_free(mgr, env);
|
def_defn.second->find_free(mgr, env);
|
||||||
dependency_graph.add_function(def_defn.second->name);
|
dependency_graph.add_function(def_defn.second->name);
|
||||||
|
|
||||||
for(auto& dependency : def_defn.second->free_variables) {
|
for(auto& dependency : def_defn.second->nearby_variables) {
|
||||||
if(defs_defn.find(dependency) == defs_defn.end())
|
if(defs_defn.find(dependency) == defs_defn.end())
|
||||||
throw 0;
|
throw 0;
|
||||||
dependency_graph.add_edge(def_defn.second->name, dependency);
|
dependency_graph.add_edge(def_defn.second->name, dependency);
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct definition_defn {
|
||||||
type_env_ptr env;
|
type_env_ptr env;
|
||||||
type_env_ptr var_env;
|
type_env_ptr var_env;
|
||||||
std::set<std::string> free_variables;
|
std::set<std::string> free_variables;
|
||||||
|
std::set<std::string> nearby_variables;
|
||||||
type_ptr full_type;
|
type_ptr full_type;
|
||||||
type_ptr return_type;
|
type_ptr return_type;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user