-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast_functions.c
42 lines (35 loc) · 967 Bytes
/
ast_functions.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <ast_functions.h>
#include <stdlib.h>
statement_call_function_t * create_call_function_statement(
char * function_name,
statement_call_function_param_t * params)
{
statement_call_function_t * new_call_function = NULL;
new_call_function = malloc(sizeof(*new_call_function));
if (NULL == new_call_function)
{
goto cleanup;
}
new_call_function->function_name = function_name;
new_call_function->params = params;
return new_call_function;
cleanup:
return NULL;
}
statement_call_function_param_t * add_call_function_parameter(
statement_call_function_param_t * previous_parameter,
statement_expression_t * parameter)
{
statement_call_function_param_t * new_parameter = malloc(sizeof(*new_parameter));
if (NULL == new_parameter)
{
goto cleanup;
}
new_parameter->next = previous_parameter;
new_parameter->parameter = parameter;
return new_parameter;
cleanup:
/* TODO free the whole list */
free(previous_parameter);
return NULL;
}