ability to call member functions directly

see #14
This commit is contained in:
Andrew Kelley
2016-01-28 16:55:54 -07:00
parent bb4f783528
commit 974d69ea3d
3 changed files with 50 additions and 13 deletions

View File

@@ -496,16 +496,25 @@ static LLVMValueRef gen_fn_call_expr(CodeGen *g, AstNode *node) {
assert(struct_type->data.pointer.child_type->id == TypeTableEntryIdStruct);
fn_table_entry = node->data.fn_call_expr.fn_entry;
} else if (struct_type->id == TypeTableEntryIdMetaType) {
TypeTableEntry *enum_type = get_type_for_type_node(first_param_expr);
int param_count = node->data.fn_call_expr.params.length;
AstNode *arg1_node;
if (param_count == 1) {
arg1_node = node->data.fn_call_expr.params.at(0);
TypeTableEntry *child_type = get_type_for_type_node(first_param_expr);
if (child_type->id == TypeTableEntryIdEnum) {
int param_count = node->data.fn_call_expr.params.length;
AstNode *arg1_node;
if (param_count == 1) {
arg1_node = node->data.fn_call_expr.params.at(0);
} else {
assert(param_count == 0);
arg1_node = nullptr;
}
return gen_enum_value_expr(g, fn_ref_expr, child_type, arg1_node);
} else if (child_type->id == TypeTableEntryIdStruct) {
struct_type = nullptr;
first_param_expr = nullptr;
fn_table_entry = node->data.fn_call_expr.fn_entry;
} else {
assert(param_count == 0);
arg1_node = nullptr;
zig_unreachable();
}
return gen_enum_value_expr(g, fn_ref_expr, enum_type, arg1_node);
} else {
zig_unreachable();
}