Added in explicit types for function values
This commit is contained in:
@@ -282,7 +282,7 @@ obj ast_transformation (Object) {
|
|||||||
println(to_ret->to_string())
|
println(to_ret->to_string())
|
||||||
return to_ret
|
return to_ret
|
||||||
}
|
}
|
||||||
// should take into account indirection and references...
|
// should take into account references...
|
||||||
if (type_syntax_str == "void")
|
if (type_syntax_str == "void")
|
||||||
return type_ptr(base_type::void_return(), indirection)
|
return type_ptr(base_type::void_return(), indirection)
|
||||||
else if (type_syntax_str == "bool")
|
else if (type_syntax_str == "bool")
|
||||||
@@ -295,9 +295,10 @@ obj ast_transformation (Object) {
|
|||||||
return type_ptr(base_type::double_precision(), indirection)
|
return type_ptr(base_type::double_precision(), indirection)
|
||||||
else if (type_syntax_str == "char")
|
else if (type_syntax_str == "char")
|
||||||
return type_ptr(base_type::character(), indirection)
|
return type_ptr(base_type::character(), indirection)
|
||||||
else if (/* check for function type*/ false)
|
else if (get_node("function_type", real_node)) {
|
||||||
return type_ptr(base_type::function(), indirection)
|
var types = get_nodes("type", get_node("function_type", real_node)).map(fun(node: *tree<symbol>): *type transform_type(node, scope, template_replacements);)
|
||||||
else {
|
return type_ptr(types.slice(0,-2), types.last(), indirection)
|
||||||
|
} else {
|
||||||
// do lookup for objects, ADTs, templates, etc
|
// do lookup for objects, ADTs, templates, etc
|
||||||
var possibilities = scope_lookup(type_syntax_str, scope)
|
var possibilities = scope_lookup(type_syntax_str, scope)
|
||||||
print("There are "); print(possibilities.size); println(" possibilites for this object type lookup")
|
print("There are "); print(possibilities.size); println(" possibilites for this object type lookup")
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ fun print_and_return(data: int): int {
|
|||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
fun main(): int {
|
fun main(): int {
|
||||||
var v = print_and_return
|
var v: fun(int):int
|
||||||
println(v(7))
|
v = print_and_return
|
||||||
|
println(v(7))
|
||||||
// println(print_and_return(7))
|
// println(print_and_return(7))
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user