This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Add method overload resolution to expression parser
- From: Tom Tromey <tromey at redhat dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 09 Nov 2009 15:22:23 -0700
- Subject: Re: [RFA] Add method overload resolution to expression parser
- References: <4A9D628B.1070300@redhat.com> <m3eip7htrx.fsf@fleche.redhat.com> <4AF88FD4.2010303@redhat.com>
- Reply-to: tromey at redhat dot com
>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:
Keith> I've attached an updated patch which I think addresses most of the
Keith> serious concerns.
Thanks.
Keith> +exp : exp '(' nonempty_typelist ')' const_or_volatile
Keith> + { int i;
Keith> + write_exp_elt_opcode (TYPE_INSTANCE);
Keith> + write_exp_elt_longcst ((LONGEST) $<ivec>3[0]);
Keith> + for (i = 0; i < $<ivec>3[0]; ++i)
Keith> + write_exp_elt_type ($<tvec>3[i + 1]);
Keith> + write_exp_elt_longcst((LONGEST) $<ivec>3[0]);
This is ok, because c-exp.y already does this, but the ivec/tvec
overloading still seems weird to me.
Keith> + case TYPE_INSTANCE:
Keith> + nargs = longest_to_int (exp->elts[pc + 1].longconst);
Keith> + arg_types = (struct type **) alloca (nargs * sizeof (struct type *));
Keith> + for (ix = 0; ix < nargs; ++ix)
Keith> + arg_types[ix] = exp->elts[pc + 1 + ix + 1].type;
Keith> +
Keith> + expect_type = make_params (nargs, arg_types);
Keith> + *(pos) += 3 + nargs;
Keith> + arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
Keith> + xfree (TYPE_FIELDS (expect_type));
Keith> + xfree (TYPE_MAIN_TYPE (expect_type));
Keith> + xfree (expect_type);
These frees should be done with cleanups, in case
evaluate_subexp_standard throws an exception.
I think free_param_types was ok, it was just that the cleanup was made in
a surprising place (make_params) and not run at the "right point" (just
before the end of the TYPE_INSTANCE case).
This is ok with that change. Thanks.
Tom