HM-style return type overloaded function infrencing works!
This commit is contained in:
@@ -32,18 +32,6 @@ adt ast {
|
||||
_cast: *binding<type>,
|
||||
_value: pair<str, *binding<type>>
|
||||
}
|
||||
fun get_type(a: *tree<ast>): *binding<type> {
|
||||
match(a->data) {
|
||||
ast::_identifier(b) return b.second
|
||||
ast::_binding(b) return get_type(b.second->bound_to)
|
||||
ast::_function(b) return b.second
|
||||
ast::_call() return get_type(a->children[0])->bound_to->base._fun.first.second
|
||||
/*ast::_compiler_intrinsic(b) return str("_compiler_intrinsic(") + b.first + ")"*/
|
||||
ast::_cast(b) return b
|
||||
ast::_value(b) return b.second
|
||||
}
|
||||
error("Trying to get type of node without one: " + to_string(a->data))
|
||||
}
|
||||
fun to_string(a: ref ast): str {
|
||||
match(a) {
|
||||
ast::_translation_unit(b) return str("_translation_unit(") + b + ")"
|
||||
|
||||
@@ -61,7 +61,23 @@ obj type (Object) {
|
||||
fun equality(other: ref type, care_about_ref: bool):bool {
|
||||
if (care_about_ref && (is_ref != other.is_ref))
|
||||
return false
|
||||
return base == other.base && indirection == other.indirection
|
||||
if (indirection != other.indirection)
|
||||
return false
|
||||
match(base) {
|
||||
base_type::_fun(b) {
|
||||
if ( !(other.is_fun() && base._fun.second == other.base._fun.second && base._fun.third == other.base._fun.third) )
|
||||
return false
|
||||
if ( !(base._fun.first.second->bound_to->equality(other.base._fun.first.second->bound_to, care_about_ref)) )
|
||||
return false
|
||||
if ( !(base._fun.first.first.size == other.base._fun.first.first.size) )
|
||||
return false
|
||||
for (var i = 0; i < base._fun.first.first.size; i++;)
|
||||
if ( !(base._fun.first.first[i]->bound_to->equality(other.base._fun.first.first[i]->bound_to, care_about_ref)) )
|
||||
return false
|
||||
return true
|
||||
}
|
||||
}
|
||||
return base == other.base
|
||||
}
|
||||
fun to_string(): str {
|
||||
var indr_string = str("")
|
||||
|
||||
Reference in New Issue
Block a user