2 * File expr.c - expression handling for Wine internal debugger.
4 * Copyright (C) 1997, Eric Youngdale.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/debug.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(winedbg
);
78 struct dbg_type cast_to
;
86 const char* element_name
;
100 #define EXPR_TYPE_S_CONST 0
101 #define EXPR_TYPE_U_CONST 1
102 #define EXPR_TYPE_SYMBOL 2
103 #define EXPR_TYPE_INTVAR 3
104 #define EXPR_TYPE_BINOP 4
105 #define EXPR_TYPE_UNOP 5
106 #define EXPR_TYPE_STRUCT 6
107 #define EXPR_TYPE_PSTRUCT 7
108 #define EXPR_TYPE_CALL 8
109 #define EXPR_TYPE_STRING 9
110 #define EXPR_TYPE_CAST 10
112 static char expr_list
[4096];
113 static unsigned int next_expr_free
= 0;
115 static struct expr
* expr_alloc(void)
119 rtn
= (struct expr
*)&expr_list
[next_expr_free
];
121 next_expr_free
+= sizeof(struct expr
);
122 assert(next_expr_free
< sizeof(expr_list
));
127 void expr_free_all(void)
132 struct expr
* expr_alloc_typecast(struct dbg_type
* type
, struct expr
* exp
)
138 ex
->type
= EXPR_TYPE_CAST
;
139 ex
->un
.cast
.cast_to
= *type
;
140 ex
->un
.cast
.expr
= exp
;
144 struct expr
* expr_alloc_internal_var(const char* name
)
150 ex
->type
= EXPR_TYPE_INTVAR
;
151 ex
->un
.intvar
.name
= name
;
155 struct expr
* expr_alloc_symbol(const char* name
)
161 ex
->type
= EXPR_TYPE_SYMBOL
;
162 ex
->un
.symbol
.name
= name
;
166 struct expr
* expr_alloc_sconstant(dbg_lgint_t value
)
172 ex
->type
= EXPR_TYPE_S_CONST
;
173 ex
->un
.s_const
.value
= value
;
177 struct expr
* expr_alloc_uconstant(dbg_lguint_t value
)
183 ex
->type
= EXPR_TYPE_U_CONST
;
184 ex
->un
.u_const
.value
= value
;
188 struct expr
* expr_alloc_string(const char* str
)
194 ex
->type
= EXPR_TYPE_STRING
;
195 ex
->un
.string
.str
= str
;
199 struct expr
* expr_alloc_binary_op(int op_type
, struct expr
* exp1
, struct expr
* exp2
)
205 ex
->type
= EXPR_TYPE_BINOP
;
206 ex
->un
.binop
.binop_type
= op_type
;
207 ex
->un
.binop
.exp1
= exp1
;
208 ex
->un
.binop
.exp2
= exp2
;
212 struct expr
* expr_alloc_unary_op(int op_type
, struct expr
* exp1
)
218 ex
->type
= EXPR_TYPE_UNOP
;
219 ex
->un
.unop
.unop_type
= op_type
;
220 ex
->un
.unop
.exp1
= exp1
;
224 struct expr
* expr_alloc_struct(struct expr
* exp
, const char* element
)
230 ex
->type
= EXPR_TYPE_STRUCT
;
231 ex
->un
.structure
.exp1
= exp
;
232 ex
->un
.structure
.element_name
= element
;
236 struct expr
* expr_alloc_pstruct(struct expr
* exp
, const char* element
)
242 ex
->type
= EXPR_TYPE_PSTRUCT
;
243 ex
->un
.structure
.exp1
= exp
;
244 ex
->un
.structure
.element_name
= element
;
248 struct expr
* WINAPIV
expr_alloc_func_call(const char* funcname
, int nargs
, ...)
256 ex
->type
= EXPR_TYPE_CALL
;
257 ex
->un
.call
.funcname
= funcname
;
258 ex
->un
.call
.nargs
= nargs
;
261 for (i
= 0; i
< nargs
; i
++)
263 ex
->un
.call
.arg
[i
] = va_arg(ap
, struct expr
*);
269 /******************************************************************
273 struct dbg_lvalue
expr_eval(struct expr
* exp
)
275 struct dbg_lvalue rtn
;
276 struct dbg_lvalue exp1
;
277 struct dbg_lvalue exp2
;
278 DWORD64 scale1
, scale2
, scale3
;
279 struct dbg_type type1
, type2
;
281 const struct dbg_internal_var
* div
;
284 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_none
, NULL
);
289 exp1
= expr_eval(exp
->un
.cast
.expr
);
290 if (exp1
.type
.id
== dbg_itype_none
)
291 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
293 rtn
.type
= exp
->un
.cast
.cast_to
;
294 init_lvalue_in_debugger(&rtn
, exp
->un
.cast
.cast_to
.module
, exp
->un
.cast
.cast_to
.id
, &exp
->un
.cast
.result
);
295 if (types_is_float_type(&exp1
))
298 ret
= memory_fetch_float(&exp1
, &dbl
);
301 if (types_is_float_type(&rtn
))
302 ret
= memory_store_float(&rtn
, &dbl
);
303 else if (types_is_integral_type(&rtn
))
304 ret
= memory_store_integer(&rtn
, (dbg_lgint_t
)dbl
);
309 else if (types_is_integral_type(&exp1
))
311 dbg_lgint_t val
= types_extract_as_integer(&exp1
);
312 if (types_is_float_type(&rtn
))
315 ret
= memory_store_float(&rtn
, &dbl
);
317 else if (types_is_integral_type(&rtn
) || types_is_pointer_type(&rtn
))
318 ret
= memory_store_integer(&rtn
, val
);
322 else if (types_is_pointer_type(&exp1
))
324 dbg_lgint_t val
= types_extract_as_integer(&exp1
);
326 if (types_is_integral_type(&rtn
) || types_is_pointer_type(&rtn
))
327 ret
= memory_store_integer(&rtn
, val
);
334 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
336 case EXPR_TYPE_STRING
:
337 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_astring
, &exp
->un
.string
.str
);
339 case EXPR_TYPE_U_CONST
:
340 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_lguint
, &exp
->un
.u_const
.value
);
342 case EXPR_TYPE_S_CONST
:
343 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_lgint
, &exp
->un
.s_const
.value
);
345 case EXPR_TYPE_SYMBOL
:
346 switch (symbol_get_lvalue(exp
->un
.symbol
.name
, -1, &rtn
, FALSE
))
351 RaiseException(DEBUG_STATUS_NO_SYMBOL
, 0, 0, NULL
);
352 /* should never be here */
354 RaiseException(DEBUG_STATUS_ABORT
, 0, 0, NULL
);
355 /* should never be here */
358 case EXPR_TYPE_PSTRUCT
:
359 exp1
= expr_eval(exp
->un
.structure
.exp1
);
360 if (exp1
.type
.id
== dbg_itype_none
|| !types_array_index(&exp1
, 0, &rtn
) ||
361 rtn
.type
.id
== dbg_itype_none
)
362 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
363 if (!types_udt_find_element(&rtn
, exp
->un
.structure
.element_name
))
365 dbg_printf("%s\n", exp
->un
.structure
.element_name
);
366 RaiseException(DEBUG_STATUS_NO_FIELD
, 0, 0, NULL
);
369 case EXPR_TYPE_STRUCT
:
370 exp1
= expr_eval(exp
->un
.structure
.exp1
);
371 if (exp1
.type
.id
== dbg_itype_none
) RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
373 if (!types_udt_find_element(&rtn
, exp
->un
.structure
.element_name
))
375 dbg_printf("%s\n", exp
->un
.structure
.element_name
);
376 RaiseException(DEBUG_STATUS_NO_FIELD
, 0, 0, NULL
);
382 * First, evaluate all of the arguments. If any of them are not
383 * evaluable, then bail.
385 for (i
= 0; i
< exp
->un
.call
.nargs
; i
++)
387 exp1
= expr_eval(exp
->un
.call
.arg
[i
]);
388 if (exp1
.type
.id
== dbg_itype_none
)
389 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
390 cexp
[i
] = types_extract_as_integer(&exp1
);
394 * Now look up the address of the function itself.
396 switch (symbol_get_lvalue(exp
->un
.call
.funcname
, -1, &rtn
, FALSE
))
401 RaiseException(DEBUG_STATUS_NO_SYMBOL
, 0, 0, NULL
);
402 /* should never be here */
404 RaiseException(DEBUG_STATUS_ABORT
, 0, 0, NULL
);
405 /* should never be here */
408 /* FIXME: NEWDBG NIY */
409 /* Anyway, I wonder how this could work depending on the calling order of
410 * the function (cdecl vs pascal for example)
414 fptr
= (int (*)()) rtn
.addr
.off
;
415 switch (exp
->un
.call
.nargs
)
418 exp
->un
.call
.result
= (*fptr
)();
421 exp
->un
.call
.result
= (*fptr
)(cexp
[0]);
424 exp
->un
.call
.result
= (*fptr
)(cexp
[0], cexp
[1]);
427 exp
->un
.call
.result
= (*fptr
)(cexp
[0], cexp
[1], cexp
[2]);
430 exp
->un
.call
.result
= (*fptr
)(cexp
[0], cexp
[1], cexp
[2], cexp
[3]);
433 exp
->un
.call
.result
= (*fptr
)(cexp
[0], cexp
[1], cexp
[2], cexp
[3], cexp
[4]);
437 dbg_printf("Function call no longer implemented\n");
438 /* would need to set up a call to this function, and then restore the current
439 * context afterwards...
441 exp
->un
.call
.result
= 0;
443 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_none
, &exp
->un
.call
.result
);
444 /* get return type from function signature type */
445 /* FIXME rtn.type.module should be set to function's module... */
446 types_get_info(&rtn
.type
, TI_GET_TYPE
, &rtn
.type
);
448 case EXPR_TYPE_INTVAR
:
449 if (!(div
= dbg_get_internal_var(exp
->un
.intvar
.name
)))
450 RaiseException(DEBUG_STATUS_NO_SYMBOL
, 0, 0, NULL
);
451 init_lvalue_in_debugger(&rtn
, 0, div
->typeid, div
->pval
);
453 case EXPR_TYPE_BINOP
:
454 exp1
= expr_eval(exp
->un
.binop
.exp1
);
455 exp2
= expr_eval(exp
->un
.binop
.exp2
);
456 if (exp1
.type
.id
== dbg_itype_none
|| exp2
.type
.id
== dbg_itype_none
)
457 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
458 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_lgint
, &exp
->un
.binop
.result
);
461 switch (exp
->un
.binop
.binop_type
)
464 if (!types_get_info(&exp1
.type
, TI_GET_SYMTAG
, &tag
) ||
465 tag
!= SymTagPointerType
||
466 !types_get_info(&exp1
.type
, TI_GET_TYPE
, &type1
))
467 type1
.id
= dbg_itype_none
;
468 if (!types_get_info(&exp2
.type
, TI_GET_SYMTAG
, &tag
) ||
469 tag
!= SymTagPointerType
||
470 !types_get_info(&exp2
.type
, TI_GET_TYPE
, &type2
))
471 type2
.id
= dbg_itype_none
;
474 if (type1
.id
!= dbg_itype_none
&& type2
.id
!= dbg_itype_none
)
475 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
476 if (type1
.id
!= dbg_itype_none
)
478 types_get_info(&type1
, TI_GET_LENGTH
, &scale2
);
479 rtn
.type
= exp1
.type
;
481 else if (type2
.id
!= dbg_itype_none
)
483 types_get_info(&type2
, TI_GET_LENGTH
, &scale1
);
484 rtn
.type
= exp2
.type
;
486 exp
->un
.binop
.result
= types_extract_as_integer(&exp1
) * (dbg_lguint_t
)scale1
+
487 (dbg_lguint_t
)scale2
* types_extract_as_integer(&exp2
);
490 if (!types_get_info(&exp1
.type
, TI_GET_SYMTAG
, &tag
) ||
491 tag
!= SymTagPointerType
||
492 !types_get_info(&exp1
.type
, TI_GET_TYPE
, &type1
))
493 type1
.id
= dbg_itype_none
;
494 if (!types_get_info(&exp2
.type
, TI_GET_SYMTAG
, &tag
) ||
495 tag
!= SymTagPointerType
||
496 !types_get_info(&exp2
.type
, TI_GET_TYPE
, &type2
))
497 type2
.id
= dbg_itype_none
;
501 if (type1
.id
!= dbg_itype_none
&& type2
.id
!= dbg_itype_none
)
503 WINE_FIXME("This may fail (if module base address are wrongly calculated)\n");
504 if (memcmp(&type1
, &type2
, sizeof(struct dbg_type
)))
505 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
506 types_get_info(&type1
, TI_GET_LENGTH
, &scale3
);
508 else if (type1
.id
!= dbg_itype_none
)
510 types_get_info(&type1
, TI_GET_LENGTH
, &scale2
);
511 rtn
.type
= exp1
.type
;
513 else if (type2
.id
!= dbg_itype_none
)
515 types_get_info(&type2
, TI_GET_LENGTH
, &scale1
);
516 rtn
.type
= exp2
.type
;
518 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) * (dbg_lguint_t
)scale1
-
519 types_extract_as_integer(&exp2
) * (dbg_lguint_t
)scale2
) / (dbg_lguint_t
)scale3
;
522 rtn
.type
.id
= dbg_itype_segptr
;
524 dbg_curr_process
->be_cpu
->build_addr(dbg_curr_thread
->handle
, &dbg_context
, &rtn
.addr
,
525 types_extract_as_integer(&exp1
), types_extract_as_integer(&exp2
));
528 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) || types_extract_as_integer(&exp2
));
531 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) && types_extract_as_integer(&exp2
));
534 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) | types_extract_as_integer(&exp2
));
537 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) & types_extract_as_integer(&exp2
));
540 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) ^ types_extract_as_integer(&exp2
));
543 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) == types_extract_as_integer(&exp2
));
546 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) > types_extract_as_integer(&exp2
));
549 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) < types_extract_as_integer(&exp2
));
552 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) >= types_extract_as_integer(&exp2
));
555 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) <= types_extract_as_integer(&exp2
));
558 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) != types_extract_as_integer(&exp2
));
561 exp
->un
.binop
.result
= types_extract_as_integer(&exp1
) << types_extract_as_integer(&exp2
);
564 exp
->un
.binop
.result
= types_extract_as_integer(&exp1
) >> types_extract_as_integer(&exp2
);
567 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) * types_extract_as_integer(&exp2
));
570 if (types_extract_as_integer(&exp2
) == 0) RaiseException(DEBUG_STATUS_DIV_BY_ZERO
, 0, 0, NULL
);
571 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) / types_extract_as_integer(&exp2
));
574 if (types_extract_as_integer(&exp2
) == 0) RaiseException(DEBUG_STATUS_DIV_BY_ZERO
, 0, 0, NULL
);
575 exp
->un
.binop
.result
= (types_extract_as_integer(&exp1
) % types_extract_as_integer(&exp2
));
578 if (!types_array_index(&exp1
, types_extract_as_integer(&exp2
), &rtn
))
579 RaiseException(DEBUG_STATUS_CANT_DEREF
, 0, 0, NULL
);
581 default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
585 exp1
= expr_eval(exp
->un
.unop
.exp1
);
586 if (exp1
.type
.id
== dbg_itype_none
) RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
587 init_lvalue_in_debugger(&rtn
, 0, dbg_itype_lgint
, &exp
->un
.unop
.result
);
588 switch (exp
->un
.unop
.unop_type
)
591 exp
->un
.unop
.result
= -types_extract_as_integer(&exp1
);
594 exp
->un
.unop
.result
= !types_extract_as_integer(&exp1
);
597 exp
->un
.unop
.result
= ~types_extract_as_integer(&exp1
);
600 if (!types_array_index(&exp1
, 0, &rtn
))
601 RaiseException(DEBUG_STATUS_BAD_TYPE
, 0, 0, NULL
);
604 /* only do it on linear addresses */
605 if (exp1
.addr
.Mode
!= AddrModeFlat
)
606 RaiseException(DEBUG_STATUS_CANT_DEREF
, 0, 0, NULL
);
607 exp
->un
.unop
.result
= (ULONG_PTR
)memory_to_linear_addr(&exp1
.addr
);
608 if (!types_find_pointer(&exp1
.type
, &rtn
.type
))
609 RaiseException(DEBUG_STATUS_CANT_DEREF
, 0, 0, NULL
);
611 default: RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
615 WINE_FIXME("Unexpected expression (%d).\n", exp
->type
);
616 RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
623 BOOL
expr_print(const struct expr
* exp
)
631 types_print_type(&exp
->un
.cast
.cast_to
, FALSE
, NULL
);
633 expr_print(exp
->un
.cast
.expr
);
636 case EXPR_TYPE_INTVAR
:
637 dbg_printf("$%s", exp
->un
.intvar
.name
);
639 case EXPR_TYPE_U_CONST
:
640 dbg_printf("%I64u", exp
->un
.u_const
.value
);
642 case EXPR_TYPE_S_CONST
:
643 dbg_printf("%I64d", exp
->un
.s_const
.value
);
645 case EXPR_TYPE_STRING
:
646 dbg_printf("\"%s\"", exp
->un
.string
.str
);
648 case EXPR_TYPE_SYMBOL
:
649 dbg_printf("%s" , exp
->un
.symbol
.name
);
651 case EXPR_TYPE_PSTRUCT
:
652 expr_print(exp
->un
.structure
.exp1
);
653 dbg_printf("->%s", exp
->un
.structure
.element_name
);
655 case EXPR_TYPE_STRUCT
:
656 expr_print(exp
->un
.structure
.exp1
);
657 dbg_printf(".%s", exp
->un
.structure
.element_name
);
660 dbg_printf("%s(",exp
->un
.call
.funcname
);
661 for (i
= 0; i
< exp
->un
.call
.nargs
; i
++)
663 expr_print(exp
->un
.call
.arg
[i
]);
664 if (i
!= exp
->un
.call
.nargs
- 1) dbg_printf(", ");
668 case EXPR_TYPE_BINOP
:
670 expr_print(exp
->un
.binop
.exp1
);
671 switch (exp
->un
.binop
.binop_type
)
673 case EXP_OP_ADD
: dbg_printf(" + "); break;
674 case EXP_OP_SUB
: dbg_printf(" - "); break;
675 case EXP_OP_SEG
: dbg_printf(":"); break;
676 case EXP_OP_LOR
: dbg_printf(" || "); break;
677 case EXP_OP_LAND
: dbg_printf(" && "); break;
678 case EXP_OP_OR
: dbg_printf(" | "); break;
679 case EXP_OP_AND
: dbg_printf(" & "); break;
680 case EXP_OP_XOR
: dbg_printf(" ^ "); break;
681 case EXP_OP_EQ
: dbg_printf(" == "); break;
682 case EXP_OP_GT
: dbg_printf(" > "); break;
683 case EXP_OP_LT
: dbg_printf(" < "); break;
684 case EXP_OP_GE
: dbg_printf(" >= "); break;
685 case EXP_OP_LE
: dbg_printf(" <= "); break;
686 case EXP_OP_NE
: dbg_printf(" != "); break;
687 case EXP_OP_SHL
: dbg_printf(" << "); break;
688 case EXP_OP_SHR
: dbg_printf(" >> "); break;
689 case EXP_OP_MUL
: dbg_printf(" * "); break;
690 case EXP_OP_DIV
: dbg_printf(" / "); break;
691 case EXP_OP_REM
: dbg_printf(" %% "); break;
692 case EXP_OP_ARR
: dbg_printf("["); break;
695 expr_print(exp
->un
.binop
.exp2
);
696 if (exp
->un
.binop
.binop_type
== EXP_OP_ARR
) dbg_printf("]");
700 switch (exp
->un
.unop
.unop_type
)
702 case EXP_OP_NEG
: dbg_printf("-"); break;
703 case EXP_OP_NOT
: dbg_printf("!"); break;
704 case EXP_OP_LNOT
: dbg_printf("~"); break;
705 case EXP_OP_DEREF
: dbg_printf("*"); break;
706 case EXP_OP_ADDR
: dbg_printf("&"); break;
708 expr_print(exp
->un
.unop
.exp1
);
711 WINE_FIXME("Unexpected expression (%u).\n", exp
->type
);
712 RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
719 struct expr
* expr_clone(const struct expr
* exp
, BOOL
*local_binding
)
724 rtn
= malloc(sizeof(struct expr
));
727 * First copy the contents of the expression itself.
734 rtn
->un
.cast
.expr
= expr_clone(exp
->un
.cast
.expr
, local_binding
);
736 case EXPR_TYPE_INTVAR
:
737 rtn
->un
.intvar
.name
= strdup(exp
->un
.intvar
.name
);
739 case EXPR_TYPE_U_CONST
:
740 case EXPR_TYPE_S_CONST
:
742 case EXPR_TYPE_STRING
:
743 rtn
->un
.string
.str
= strdup(exp
->un
.string
.str
);
745 case EXPR_TYPE_SYMBOL
:
746 rtn
->un
.symbol
.name
= strdup(exp
->un
.symbol
.name
);
747 if (local_binding
&& symbol_is_local(exp
->un
.symbol
.name
))
748 *local_binding
= TRUE
;
750 case EXPR_TYPE_PSTRUCT
:
751 case EXPR_TYPE_STRUCT
:
752 rtn
->un
.structure
.exp1
= expr_clone(exp
->un
.structure
.exp1
, local_binding
);
753 rtn
->un
.structure
.element_name
= strdup(exp
->un
.structure
.element_name
);
756 for (i
= 0; i
< exp
->un
.call
.nargs
; i
++)
758 rtn
->un
.call
.arg
[i
] = expr_clone(exp
->un
.call
.arg
[i
], local_binding
);
760 rtn
->un
.call
.funcname
= strdup(exp
->un
.call
.funcname
);
762 case EXPR_TYPE_BINOP
:
763 rtn
->un
.binop
.exp1
= expr_clone(exp
->un
.binop
.exp1
, local_binding
);
764 rtn
->un
.binop
.exp2
= expr_clone(exp
->un
.binop
.exp2
, local_binding
);
767 rtn
->un
.unop
.exp1
= expr_clone(exp
->un
.unop
.exp1
, local_binding
);
770 WINE_FIXME("Unexpected expression (%u).\n", exp
->type
);
771 RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);
780 * Recursively go through an expression tree and free all memory associated
783 BOOL
expr_free(struct expr
* exp
)
790 expr_free(exp
->un
.cast
.expr
);
792 case EXPR_TYPE_INTVAR
:
793 free((char*)exp
->un
.intvar
.name
);
795 case EXPR_TYPE_U_CONST
:
796 case EXPR_TYPE_S_CONST
:
798 case EXPR_TYPE_STRING
:
799 free((char*)exp
->un
.string
.str
);
801 case EXPR_TYPE_SYMBOL
:
802 free((char*)exp
->un
.symbol
.name
);
804 case EXPR_TYPE_PSTRUCT
:
805 case EXPR_TYPE_STRUCT
:
806 expr_free(exp
->un
.structure
.exp1
);
807 free((char*)exp
->un
.structure
.element_name
);
810 for (i
= 0; i
< exp
->un
.call
.nargs
; i
++)
812 expr_free(exp
->un
.call
.arg
[i
]);
814 free((char*)exp
->un
.call
.funcname
);
816 case EXPR_TYPE_BINOP
:
817 expr_free(exp
->un
.binop
.exp1
);
818 expr_free(exp
->un
.binop
.exp2
);
821 expr_free(exp
->un
.unop
.exp1
);
824 WINE_FIXME("Unexpected expression (%u).\n", exp
->type
);
825 RaiseException(DEBUG_STATUS_INTERNAL_ERROR
, 0, 0, NULL
);