Fixed up a bug and 2 tests, plus added a better error for when a method isn't found. 69 tests passing! This is everything before ADTs (because of some tests with no success condition, some that depend on the compiler stdlib parts, etc)

This commit is contained in:
Nathan Braswell
2016-03-12 04:46:49 -05:00
parent 6a1c210b8a
commit 6fff4c5363
4 changed files with 34 additions and 45 deletions

View File

@@ -693,8 +693,10 @@ obj ast_transformation (Object) {
if (is_template(enclosing) && is_type_def(enclosing->template.scope[string("~enclosing_scope")][0])) if (is_template(enclosing) && is_type_def(enclosing->template.scope[string("~enclosing_scope")][0]))
return set(make_this(enclosing->template.scope[string("~enclosing_scope")][0])) return set(make_this(enclosing->template.scope[string("~enclosing_scope")][0]))
} }
// we don't close over actual functions // if this is a lambda, we need to close over what it closes over
return set<*ast_node>() // we don't need an if - if it's empty and not a lambda, it's empty
// and we don't close over actual functions
return backing.closed_variables
} }
ast_node::return_statement(backing) { ast_node::return_statement(backing) {
println("found an return_statement") println("found an return_statement")
@@ -799,12 +801,14 @@ obj ast_transformation (Object) {
for (var i = 0; i < parent->template.template_types.size; i++;) for (var i = 0; i < parent->template.template_types.size; i++;)
inherited_replacements[parent->template.template_types[i]] = parent->template.instantiated_map.reverse_get(get_ast_type(first_param)->type_def)[i].clone() inherited_replacements[parent->template.template_types[i]] = parent->template.instantiated_map.reverse_get(get_ast_type(first_param)->type_def)[i].clone()
} }
var method_name = concat_symbol_tree(node->children[2])
if (template_inst) if (template_inst)
second_param = find_or_instantiate_template_function(concat_symbol_tree(node->children[2]), template_inst, get_ast_type(first_param)->type_def, type_vec, template_replacements, inherited_replacements); second_param = find_or_instantiate_template_function(method_name, template_inst, get_ast_type(first_param)->type_def, type_vec, template_replacements, inherited_replacements);
else else
second_param = find_or_instantiate_template_function(concat_symbol_tree(node->children[2]), null<tree<symbol>>(), get_ast_type(first_param)->type_def, type_vec, template_replacements, inherited_replacements); second_param = find_or_instantiate_template_function(method_name, null<tree<symbol>>(), get_ast_type(first_param)->type_def, type_vec, template_replacements, inherited_replacements);
if (!second_param) if (!second_param) {
error("Could not find method!") error(string("Could not find method ") + method_name + " on the right side of (. or ->) " + concat_symbol_tree(node->children[0]) + ", whole string: " + concat_symbol_tree(node))
}
} }
} }
} else { } else {

View File

@@ -18,20 +18,16 @@ copy construct from 1 to 2
copy construct from 101 to 102 copy construct from 101 to 102
copy construct from 2 to 3 copy construct from 2 to 3
copy construct from 102 to 103 copy construct from 102 to 103
destruct with 102
destruct with 2 destruct with 2
destruct with 102
destruct with 101
destruct with 1
copy construct from 3 to 4 copy construct from 3 to 4
copy construct from 103 to 104 copy construct from 103 to 104
destruct with 3 destruct with 3
destruct with 103 destruct with 103
destruct with 101 done
destruct with 1
copy construct from 4 to 5
copy construct from 104 to 105
destruct with 4 destruct with 4
destruct with 104 destruct with 104
done
destruct with 5
destruct with 105
destruct with 100 destruct with 100
destruct with 0 destruct with 0

View File

@@ -10,10 +10,8 @@ with references
123456789101112 123456789101112
Constructed: 0 Constructed: 0
Copied: 0 to 1 Copied: 0 to 1
Copied: 1 to 2
Destroyed: 1
delete vector delete vector
Destroyed: 2 Destroyed: 1
hayyy hayyy
4.700000 4.700000
first first
@@ -53,41 +51,29 @@ Copied: 100 to 101
Copied: 200 to 201 Copied: 200 to 201
Copied: 300 to 301 Copied: 300 to 301
Copied: 101 to 102 Copied: 101 to 102
Copied: 102 to 103
Copied: 103 to 104
Destroyed: 103
Destroyed: 102
Copied: 201 to 202 Copied: 201 to 202
Copied: 202 to 203
Copied: 203 to 204
Destroyed: 203
Destroyed: 202
Copied: 301 to 302 Copied: 301 to 302
Copied: 102 to 103
Copied: 202 to 203
Copied: 302 to 303 Copied: 302 to 303
Copied: 303 to 304 Destroyed: 102
Destroyed: 303 Destroyed: 202
Destroyed: 302 Destroyed: 302
Copied: 104 to 105
Copied: 204 to 205
Copied: 304 to 305
Destroyed: 104
Destroyed: 204
Destroyed: 304
Destroyed: 301 Destroyed: 301
Destroyed: 201 Destroyed: 201
Destroyed: 101 Destroyed: 101
Copied: 105 to 106 Copied: 103 to 104
Copied: 205 to 206 Copied: 203 to 204
Copied: 305 to 306 Copied: 303 to 304
Destroyed: 105 Destroyed: 103
Destroyed: 205 Destroyed: 203
Destroyed: 305 Destroyed: 303
Destroyed: 206 Destroyed: 204
Copied: 306 to 307 Copied: 304 to 305
Destroyed: 306 Destroyed: 304
done done
Destroyed: 106 Destroyed: 104
Destroyed: 307 Destroyed: 305
Destroyed: 300 Destroyed: 300
Destroyed: 200 Destroyed: 200
Destroyed: 100 Destroyed: 100

View File

@@ -5,10 +5,13 @@ import vector_literals:*
obj AbleToBeDestroyed (Object) { obj AbleToBeDestroyed (Object) {
var data:int var data:int
fun construct(dat:int):void { // needed to put it in the vector becuase serilization uses pairs, which defines an empty constructor
fun construct(): *AbleToBeDestroyed return this;
fun construct(dat:int): *AbleToBeDestroyed {
data = dat data = dat
print("Constructed: ") print("Constructed: ")
println(data) println(data)
return this
} }
fun copy_construct(other:*AbleToBeDestroyed):void { fun copy_construct(other:*AbleToBeDestroyed):void {
data = other->data+1 data = other->data+1