More work. Doesn't compile at this point

This commit is contained in:
Nathan Braswell
2017-02-23 01:24:22 -05:00
parent cb8124afc0
commit 8a676a1b5b
3 changed files with 42 additions and 4 deletions

View File

@@ -49,9 +49,9 @@ fun is_dot_style_method_call(node: *ast_node): bool {
fun function_satisfies_params(node: *ast_node, param_types: vector<*type>): bool {
var func_type = get_ast_type(node)
var func_param_types = func_type->parameter_types
var param_string = string()
param_types.for_each(fun(t: *type) param_string += t->to_string() + ", ";)
if (!func_type->is_variadic && func_param_types.size != param_types.size) {
var param_string = string()
param_types.for_each(fun(t: *type) param_string += t->to_string() + ", ";)
/*println(string("type sizes don't match ") + param_types.size + " with needed " + param_string)*/
return false
} else if (param_types.size < func_param_types.size) {
@@ -70,6 +70,19 @@ fun function_satisfies_params(node: *ast_node, param_types: vector<*type>): bool
}
return true
}
fun access_expression(left: *ast_node, right: *char): *ast_node return access_expression(left, string(right))
fun access_expression(left: *ast_node, right: ref string): *ast_node {
var ltype = get_ast_type(left)
if (!ltype->is_object())
error("Trying to generate an access expression and the left side is not an object")
var ident = identifier_lookup(right, ltype->type_def)
if (!ident)
error("Trying to generate an access expression, can't find right: " + right)
if (ltype->indirection)
return make_operator_call("->", vector(left, ident))
return make_operator_call(".", vector(left, ident))
}
fun function_lookup(name: string, scope: *ast_node, param_types: vector<*type>): *ast_node {
var results = scope_lookup(name, scope)
for (var i = 0; i < results.size; i++;) {