126 if (!match)
127 continue;
128
129 if (late == EARLY || late == BOTH) {
130 if (hooks[sm->owner])
131 (hooks[sm->owner])(sm, mod_expr);
132 }
133 if (late == LATE || late == BOTH) {
134 if (hooks_late[sm->owner])
135 (hooks_late[sm->owner])(sm, mod_expr);
136 }
137
138 } END_FOR_EACH_SM(sm);
139 }
140
141 static void call_modification_hooks(struct expression *expr, struct expression *mod_expr, int late)
142 {
143 char *name;
144 struct symbol *sym;
145
146 if (late == LATE)
147 update_mtag_data(expr);
148
149 name = expr_to_known_chunk_sym(expr, &sym);
150 if (!name)
151 goto free;
152 call_modification_hooks_name_sym(name, sym, mod_expr, late);
153 free:
154 free_string(name);
155 }
156
157 static void db_param_add(struct expression *expr, int param, char *key, char *value)
158 {
159 struct expression *arg, *gen_expr;
160 char *name, *other_name;
161 struct symbol *sym, *other_sym;
162
163 while (expr->type == EXPR_ASSIGNMENT)
164 expr = strip_expr(expr->right);
165 if (expr->type != EXPR_CALL)
166 return;
167
168 arg = get_argument_from_call_expr(expr->args, param);
169 if (!arg)
170 return;
171
172 gen_expr = gen_expression_from_key(arg, key);
173 if (gen_expr)
174 update_mtag_data(gen_expr);
175
176 name = get_variable_from_key(arg, key, &sym);
177 if (!name || !sym)
178 goto free;
179
180 __in_fake_assign++;
181 call_modification_hooks_name_sym(name, sym, expr, BOTH);
182 __in_fake_assign--;
183
184 other_name = get_other_name_sym(name, sym, &other_sym);
185 if (other_name) {
186 __in_fake_assign++;
187 call_modification_hooks_name_sym(other_name, other_sym, expr, BOTH);
188 __in_fake_assign--;
189 free_string(other_name);
190 }
191
192 free:
193 free_string(name);
194 }
195
209 static void match_call(struct expression *expr)
210 {
211 struct expression *arg, *tmp;
212
213 /* If we have the DB then trust the DB */
214 if (!option_no_db)
215 return;
216
217 FOR_EACH_PTR(expr->args, arg) {
218 tmp = strip_expr(arg);
219 if (tmp->type == EXPR_PREOP && tmp->op == '&')
220 call_modification_hooks(tmp->unop, expr, BOTH);
221 else
222 call_modification_hooks(deref_expression(tmp), expr, BOTH);
223 } END_FOR_EACH_PTR(arg);
224 }
225
226 static void asm_expr(struct statement *stmt, int late)
227 {
228 struct expression *expr;
229 int state = 0;
230
231 FOR_EACH_PTR(stmt->asm_outputs, expr) {
232 switch (state) {
233 case 0: /* identifier */
234 case 1: /* constraint */
235 state++;
236 continue;
237 case 2: /* expression */
238 state = 0;
239 call_modification_hooks(expr, NULL, late);
240 continue;
241 }
242 } END_FOR_EACH_PTR(expr);
243 }
244
245
246 static void match_assign_early(struct expression *expr)
247 {
248 match_assign(expr, EARLY);
249 }
250
251 static void unop_expr_early(struct expression *expr)
252 {
253 unop_expr(expr, EARLY);
254 }
255
256 static void asm_expr_early(struct statement *stmt)
257 {
258 asm_expr(stmt, EARLY);
259 }
260
261 static void match_assign_late(struct expression *expr)
262 {
263 match_assign(expr, LATE);
264 }
265
|
126 if (!match)
127 continue;
128
129 if (late == EARLY || late == BOTH) {
130 if (hooks[sm->owner])
131 (hooks[sm->owner])(sm, mod_expr);
132 }
133 if (late == LATE || late == BOTH) {
134 if (hooks_late[sm->owner])
135 (hooks_late[sm->owner])(sm, mod_expr);
136 }
137
138 } END_FOR_EACH_SM(sm);
139 }
140
141 static void call_modification_hooks(struct expression *expr, struct expression *mod_expr, int late)
142 {
143 char *name;
144 struct symbol *sym;
145
146 name = expr_to_known_chunk_sym(expr, &sym);
147 if (!name)
148 goto free;
149 call_modification_hooks_name_sym(name, sym, mod_expr, late);
150 free:
151 free_string(name);
152 }
153
154 static void db_param_add(struct expression *expr, int param, char *key, char *value)
155 {
156 struct expression *arg;
157 char *name, *other_name;
158 struct symbol *sym, *other_sym;
159
160 while (expr->type == EXPR_ASSIGNMENT)
161 expr = strip_expr(expr->right);
162 if (expr->type != EXPR_CALL)
163 return;
164
165 arg = get_argument_from_call_expr(expr->args, param);
166 if (!arg)
167 return;
168
169 name = get_variable_from_key(arg, key, &sym);
170 if (!name || !sym)
171 goto free;
172
173 __in_fake_assign++;
174 call_modification_hooks_name_sym(name, sym, expr, BOTH);
175 __in_fake_assign--;
176
177 other_name = get_other_name_sym(name, sym, &other_sym);
178 if (other_name) {
179 __in_fake_assign++;
180 call_modification_hooks_name_sym(other_name, other_sym, expr, BOTH);
181 __in_fake_assign--;
182 free_string(other_name);
183 }
184
185 free:
186 free_string(name);
187 }
188
202 static void match_call(struct expression *expr)
203 {
204 struct expression *arg, *tmp;
205
206 /* If we have the DB then trust the DB */
207 if (!option_no_db)
208 return;
209
210 FOR_EACH_PTR(expr->args, arg) {
211 tmp = strip_expr(arg);
212 if (tmp->type == EXPR_PREOP && tmp->op == '&')
213 call_modification_hooks(tmp->unop, expr, BOTH);
214 else
215 call_modification_hooks(deref_expression(tmp), expr, BOTH);
216 } END_FOR_EACH_PTR(arg);
217 }
218
219 static void asm_expr(struct statement *stmt, int late)
220 {
221 struct expression *expr;
222
223 FOR_EACH_PTR(stmt->asm_outputs, expr) {
224 if (expr->type != EXPR_ASM_OPERAND)
225 continue;
226 call_modification_hooks(expr->expr, NULL, late);
227 } END_FOR_EACH_PTR(expr);
228 }
229
230 static void match_assign_early(struct expression *expr)
231 {
232 match_assign(expr, EARLY);
233 }
234
235 static void unop_expr_early(struct expression *expr)
236 {
237 unop_expr(expr, EARLY);
238 }
239
240 static void asm_expr_early(struct statement *stmt)
241 {
242 asm_expr(stmt, EARLY);
243 }
244
245 static void match_assign_late(struct expression *expr)
246 {
247 match_assign(expr, LATE);
248 }
249
|