MOve it forwards a bit

This commit is contained in:
Nathan Braswell
2017-06-13 01:29:56 -04:00
3 changed files with 9 additions and 4 deletions

View File

@@ -189,7 +189,7 @@ obj ast_transformation (Object) {
var copy_construct_param = ast_identifier_ptr(string("in"), node->adt_def.self_type->clone_with_indirection(1,false), node)
var assign_param = ast_identifier_ptr(string("in"), node->adt_def.self_type->clone_with_indirection(0,true), node)
vector(
make_pair("operator==", ast_function_ptr(string("operator=="), type_ptr(vector(equals_param->identifier.type), type_ptr(base_type::boolean()), 0, false, false, false), vector(equals_param), false)),
make_pair("operator==", ast_function_ptr(string("operator=="), type_ptr(vector(equals_param->identifier.type), type_ptr(base_type::boolean()), 0, false, false, true), vector(equals_param), false)),
make_pair("operator!=", ast_function_ptr(string("operator!="), type_ptr(vector(nequals_param->identifier.type), type_ptr(base_type::boolean()), 0, false, false, true), vector(nequals_param), false)),
make_pair("construct", ast_function_ptr(string("construct"), type_ptr(vector<*type>(), node->adt_def.self_type->clone_with_increased_indirection(), 0, false, false, true), vector<*ast_node>(), false)),
make_pair("copy_construct", ast_function_ptr(string("copy_construct"), type_ptr(vector(copy_construct_param->identifier.type), type_ptr(base_type::void_return()), 0, false, false, true), vector(copy_construct_param), false)),

View File

@@ -43,9 +43,8 @@ fun function_value_lower(name_ast_map: *map<string, pair<*tree<symbol>,*ast_node
match(*node) {
ast_node::identifier(backing) {
// see if this identifier use is a closed variable in a closure
var enclosing_func = parent_chain->item_from_top_satisfying(fun(n: *ast_node): bool return is_function(n);)
if (enclosing_func->function.closed_variables.contains(node)) {
println(backing.name + " is being used in a closed fashion")
var enclosing_func = parent_chain->item_from_top_satisfying_or(fun(n: *ast_node): bool return is_function(n);, null<ast_node>())
if (enclosing_func && enclosing_func->function.closed_variables.contains(node)) {
closed_over_uses.add(make_pair(node, make_pair(parent_chain->top(), enclosing_func)))
}
}

View File

@@ -96,4 +96,10 @@ obj stack<T> (Object, Serializable) {
fun item_from_top_satisfying(func: fun(T):bool): T {
return from_top(index_from_top_satisfying(func))
}
fun item_from_top_satisfying_or(func: fun(T):bool, other: T): T {
var idx = index_from_top_satisfying(func)
if (idx != -1)
return from_top(idx)
return other
}
}