86 void *search_list(list_c *list) { |
86 void *search_list(list_c *list) { |
87 switch (current_operation) { |
87 switch (current_operation) { |
88 case iterate_op: |
88 case iterate_op: |
89 for(int i = 0; i < list->n; i++) { |
89 for(int i = 0; i < list->n; i++) { |
90 void *res = list->elements[i]->accept(*this); |
90 void *res = list->elements[i]->accept(*this); |
91 if (NULL != res) { |
91 if (NULL != res) { |
92 /* It went through the handle_parameter_assignment() function, |
92 /* It went through the handle_parameter_assignment() function, |
93 * and is therefore a parameter assignment (<param> = <value>), |
93 * and is therefore a parameter assignment (<param> = <value>), |
94 * and not a simple expression (<value>). |
94 * and not a simple expression (<value>). |
95 */ |
95 */ |
96 /* we do nothing... */ |
96 /* we do nothing... */ |
97 } else { |
97 } else { |
98 param_count++; |
98 param_count++; |
99 if (param_count == next_param) { |
99 if (param_count == next_param) { |
100 return list->elements[i]; |
100 return list->elements[i]; |
101 } |
101 } |
102 } |
102 } |
103 } |
103 } |
104 return NULL; |
104 return NULL; |
105 break; |
105 break; |
106 |
106 |
107 case search_op: |
107 case search_op: |
108 for(int i = 0; i < list->n; i++) { |
108 for(int i = 0; i < list->n; i++) { |
109 void *res = list->elements[i]->accept(*this); |
109 void *res = list->elements[i]->accept(*this); |
110 if (res != NULL) |
110 if (res != NULL) |
111 return res; |
111 return res; |
112 } |
112 } |
113 return NULL; |
113 return NULL; |
114 break; |
114 break; |
115 } /* switch */ |
115 } /* switch */ |
116 return NULL; |
116 return NULL; |
117 } |
117 } |
118 |
118 |
119 |
119 |
120 |
120 |
121 void *handle_parameter_assignment(symbol_c *variable_name, symbol_c *expression) { |
121 void *handle_parameter_assignment(symbol_c *variable_name, symbol_c *expression) { |
122 switch (current_operation) { |
122 switch (current_operation) { |
123 case iterate_op: |
123 case iterate_op: |
124 /* UGLY HACK -> this will be detected in the search_list() function */ |
124 /* UGLY HACK -> this will be detected in the search_list() function */ |
125 return (void *)this; /* anything, as long as it is not NULL!! */ |
125 return (void *)this; /* anything, as long as it is not NULL!! */ |
126 break; |
126 break; |
127 |
127 |
128 case search_op: |
128 case search_op: |
129 identifier_c *variable_name2 = dynamic_cast<identifier_c *>(variable_name); |
129 identifier_c *variable_name2 = dynamic_cast<identifier_c *>(variable_name); |
130 if (variable_name2 == NULL) ERROR; |
130 if (variable_name2 == NULL) ERROR; |
131 if (strcasecmp(search_param_name->value, variable_name2->value) == 0) |
131 if (strcasecmp(search_param_name->value, variable_name2->value) == 0) |
132 /* FOUND! This is the same parameter!! */ |
132 /* FOUND! This is the same parameter!! */ |
133 return (void *)expression; |
133 return (void *)expression; |
134 return NULL; |
134 return NULL; |
135 break; |
135 break; |
136 } |
136 } |
137 |
137 |
138 ERROR; |
138 ERROR; |
139 return NULL; |
139 return NULL; |
140 } |
140 } |
464 /* |
464 /* |
465 SYM_REF2(function_invocation_c, function_name, parameter_assignment_list) |
465 SYM_REF2(function_invocation_c, function_name, parameter_assignment_list) |
466 */ |
466 */ |
467 void *visit(function_invocation_c *symbol) { |
467 void *visit(function_invocation_c *symbol) { |
468 TRACE("function_invocation_c"); |
468 TRACE("function_invocation_c"); |
469 return symbol->parameter_assignment_list->accept(*this); |
469 if ((symbol_c *)symbol == f_call) |
|
470 return symbol->parameter_assignment_list->accept(*this); |
|
471 else |
|
472 return NULL; |
470 } |
473 } |
471 |
474 |
472 |
475 |
473 |
476 |
474 |
477 |