Function lookup now handles overloading

This commit is contained in:
Nathan Braswell
2016-01-14 12:57:16 -05:00
parent fe6818edfc
commit 785c6a6a8e
2 changed files with 32 additions and 9 deletions

View File

@@ -38,17 +38,19 @@ obj type (Object) {
base.copy_construct(&base_type::none())
parameter_types.construct()
indirection = 0
return_type = null<type>()
return this
}
fun construct(base_in: base_type, indirection_in: int): *type {
base.copy_construct(&base_in)
parameter_types.construct()
indirection = indirection_in
return_type = null<type>()
return this
}
fun construct(parameter_types_in: vector<*type>, return_type_in: *type, indirection_in: int): *type {
base.copy_construct(&base_type::function())
parameter_types.copy_construct(&parameter_types)
parameter_types.copy_construct(&parameter_types_in)
return_type = return_type_in
indirection = indirection_in
return this
@@ -67,6 +69,12 @@ obj type (Object) {
base.destruct()
parameter_types.destruct()
}
fun operator!=(other: ref type):bool return !(*this == other);
fun operator==(other: ref type):bool {
if ( (return_type && other.return_type && *return_type != *other.return_type) || (return_type && !other.return_type) || (!return_type && other.return_type) )
return false
return base == other.base && parameter_types == other.parameter_types && indirection == other.indirection
}
fun to_string(): string {
match (base) {
base_type::none() return string("none, indirection: ") + indirection