Commit 1dd111a4 authored by Guillaume Charifi's avatar Guillaume Charifi

compiler/parser: Handle constructor declaration.

parent e02ea2ef
......@@ -789,22 +789,39 @@ static int parse_decl_func(struct parser_ctx *ctx, unsigned long *cur_tok_id, st
decl.base.name = NULL;
buffer_init(&decl.param_names);
/* The storage for the last param was allocated in the loop. */
result = parse_type(ctx, &i, &ret_type);
if (result < 0)
goto failed_ret_type;
if (class_type && ctx->in->tokens[i].type == BM_TOK_NEW)
{
create_empty_class_path(&ret_type.class_path);
ret_type.class_name = str_dup(L"Void");
ret_type.nb_generic_params = 0;
ret_type.generic_params = NULL;
if (ctx->in->tokens[i].type != BM_TOK_IDENTIFIER)
goto failed;
if (!ret_type.class_name)
goto failed_ret_type;
result = parse_func_name(ctx->in->tokens[i].data.as_wstr);
if (result < 0)
goto failed;
decl.base.name = str_dup(L"new");
if (!decl.base.name)
goto failed;
i++;
}
else
{
result = parse_type(ctx, &i, &ret_type);
if (result < 0)
goto failed_ret_type;
decl.base.name = str_dup(ctx->in->tokens[i].data.as_wstr);
if (!decl.base.name)
goto failed;
i++;
if (ctx->in->tokens[i].type != BM_TOK_IDENTIFIER)
goto failed;
result = parse_func_name(ctx->in->tokens[i].data.as_wstr);
if (result < 0)
goto failed;
decl.base.name = str_dup(ctx->in->tokens[i].data.as_wstr);
if (!decl.base.name)
goto failed;
i++;
}
buffer_init(&decl.param_names);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment