+2003-09-19 David Carlton <carlton@kealia.com>
+
+ * expression.h (enum exp_opcode): Revert to mainline's OP_FUNCALL,
+ OP_SCOPE.
+ * ada-exp.y, m2-exp.y, objc-exp.y, p-exp.y: Ditto.
+ * jv-exp.y (push_qualified_expression_name): Ditto.
+ * ada-lang.c (ada_resolve_subexp, replace_operator_with_call)
+ (ada_evaluate_subexp): Ditto.
+ * eval.c (evaluate_subexp_standard): Ditto.
+ * expprint.c (print_subexp, dump_subexp): Ditto.
+ * parse.c (length_of_subexp, prefixify_subexp): Ditto.
+ * c-exp.y: Ditto, and add comment.
+ * cp-support.c (make_symbol_overload_list): Delete 'block'
+ argument; change calls to make_symbol_overload_list_using
+ appropriately.
+ (make_symbol_overload_list_using): Delete 'block' argument;
+ replace it by get_selected_block (0).
+ * cp-support.h: Delete 'block' argument from
+ make_symbol_overload_list.
+ * valops.c (find_overload_match): Delete 'block' argument, and
+ update calls using it.
+ (find_oload_champ_namespace, find_oload_champ_namespace_loop)
+ (value_aggregate_elt, value_struct_elt_for_reference)
+ (value_namespace_elt): Ditto.
+ (value_maybe_namespace_elt): Delete 'block' argument, and use
+ get_selected_block (0) instead.
+ * value.h: Delete 'block' argument from value_struct_elt,
+ value_find_oload.
+
2003-09-17 David Carlton <carlton@kealia.com>
* Merge with mainline; tag is carlton_dictionary-20030917-merge.
{
write_exp_elt_opcode (OP_FUNCALL);
write_exp_elt_longcst ($3);
- write_exp_elt_block (expression_context_block);
write_exp_elt_opcode (OP_FUNCALL);
}
;
{
write_exp_elt_opcode (OP_FUNCALL);
write_exp_elt_longcst ((LONGEST) 1);
- write_exp_elt_block (expression_context_block);
write_exp_elt_opcode (OP_FUNCALL);
}
else if (slice_state == LOWER_BOUND)
break;
case OP_FUNCALL:
- /* FIXME: carlton/2002-01-20: I don't understand this well
- enough to know if it should be changed after I added the
- current block to an OP_FUNCALL. */
nargs = longest_to_int (exp->elts[pc + 1].longconst) + 1;
/* FIXME: OP_UNRESOLVED_VALUE should be defined in expression.h */
/* if (exp->elts[pc+3].opcode == OP_UNRESOLVED_VALUE)
newexp->elts[pc].opcode = newexp->elts[pc + 2].opcode = OP_FUNCALL;
newexp->elts[pc + 1].longconst = (LONGEST) nargs;
- newexp->elts[pc + 2].block = block;
- newexp->elts[pc + 4].opcode = newexp->elts[pc + 6].opcode = OP_VAR_VALUE;
- newexp->elts[pc + 5].block = block;
- newexp->elts[pc + 6].symbol = sym;
+ newexp->elts[pc + 3].opcode = newexp->elts[pc + 6].opcode = OP_VAR_VALUE;
+ newexp->elts[pc + 4].block = block;
+ newexp->elts[pc + 5].symbol = sym;
*expp = newexp;
xfree (exp);
return value_array (tem2, tem3, argvec);
case OP_FUNCALL:
- (*pos) += 3;
+ (*pos) += 2;
/* Allocate arg vector, including space for the function to be
called in argvec[0] and a terminating NULL */
arglist ')' %prec ARROW
{ write_exp_elt_opcode (OP_FUNCALL);
write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_block (expression_context_block);
write_exp_elt_opcode (OP_FUNCALL); }
;
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (type);
- /* If it's a namespace, we need to know the
- block. */
- write_exp_elt_block (expression_context_block);
write_exp_string ($3);
write_exp_elt_opcode (OP_SCOPE);
}
destructor_name_p (tmp_token.ptr, type);
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (type);
- write_exp_elt_block (expression_context_block);
write_exp_string (tmp_token);
write_exp_elt_opcode (OP_SCOPE);
}
| qualified_type
;
+/* FIXME: carlton/2003-09-19: This leads to lots of reduce-reduce
+ conflicts, because the parser doesn't know whether or not to use
+ qualified_name or qualified_type. There's no good way to fix this
+ with the grammar as it stands; as far as I can tell, some of the
+ problems arise from ambiguities that GDB introduces ('start' can be
+ either an expression or a type), but some of it is inherent to the
+ nature of C++ (you want to treat the input "(FOO)" fairly
+ differently depending on whether FOO is an expression or a type,
+ and if FOO is a complex expression, this can be hard to determine
+ at the right time.
+
+ Perhaps we could fix this by making the lexer smarter. (Some of
+ this functionality used to be in the lexer, but in a way that
+ worked even less well than the current solution.) Ideally, the
+ code in question could be shared by the lexer and by decode_line_1.
+ I'm not holding my breath waiting for somebody to get around to
+ cleaning this up, however... */
+
qualified_type: typebase COLONCOLON name
{
struct type *type = $1;
const char *oload_name);
static void make_symbol_overload_list_using (const char *func_name,
- const char *namespace,
- const struct block *block);
+ const char *namespace);
static void make_symbol_overload_list_qualified (const char *func_name);
used in finding all overloaded instances of a function name. This
has been modified from make_symbol_completion_list. */
-/* FIXME: carlton/2003-01-30: Should BLOCK be here? Maybe it's better
- to use get_selected_block (0). */
-
struct symbol **
make_symbol_overload_list (const char *func_name,
- const char *namespace,
- const struct block *block)
+ const char *namespace)
{
struct cleanup *old_cleanups;
old_cleanups = make_cleanup (xfree, sym_return_val);
- make_symbol_overload_list_using (func_name, namespace,
- block);
+ make_symbol_overload_list_using (func_name, namespace);
discard_cleanups (old_cleanups);
static void
make_symbol_overload_list_using (const char *func_name,
- const char *namespace,
- const struct block *block)
+ const char *namespace)
{
const struct using_direct *current;
look in the appropriate namespaces for new functions to match
on. */
- for (current = block_using (block);
+ for (current = block_using (get_selected_block (0));
current != NULL;
current = current->next)
{
if (strcmp (namespace, current->outer) == 0)
{
make_symbol_overload_list_using (func_name,
- current->inner,
- block);
+ current->inner);
}
}
extern char *remove_params (const char *demangled_name);
extern struct symbol **make_symbol_overload_list (const char *,
- const char *,
- const struct block *);
+ const char *);
/* Functions/variables from cp-namespace.c. */
long mem_offset;
struct type **arg_types;
int save_pos1;
- const struct block *current_block;
pc = (*pos)++;
op = exp->elts[pc].opcode;
switch (op)
{
case OP_SCOPE:
- tem = longest_to_int (exp->elts[pc + 3].longconst);
- (*pos) += 5 + BYTES_TO_EXP_ELEM (tem + 1);
+ tem = longest_to_int (exp->elts[pc + 2].longconst);
+ (*pos) += 4 + BYTES_TO_EXP_ELEM (tem + 1);
arg1 = value_aggregate_elt (exp->elts[pc + 1].type,
- exp->elts[pc + 2].block,
- &exp->elts[pc + 4].string,
+ &exp->elts[pc + 3].string,
noside);
if (arg1 == NULL)
- error ("There is no field named %s", &exp->elts[pc + 4].string);
+ error ("There is no field named %s", &exp->elts[pc + 3].string);
return arg1;
case OP_LONG:
break;
case OP_FUNCALL:
- (*pos) += 3;
+ (*pos) += 2;
op = exp->elts[*pos].opcode;
nargs = longest_to_int (exp->elts[pc + 1].longconst);
- current_block = exp->elts[pc + 2].block;
-
/* Allocate arg vector, including space for the function to be
called in argvec[0] and a terminating NULL */
argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3));
1 /* method */,
0 /* strict match */ ,
&arg2 /* the object */, NULL,
- current_block,
&valp, NULL, &static_memfuncp);
0 /* strict match */ ,
NULL,
exp->elts[save_pos1+2].symbol /* the function */ ,
- current_block,
NULL, &symp, NULL);
/* Now fix the expression being evaluated */
{
if (op == OP_SCOPE)
{
- int temm = longest_to_int (exp->elts[pc + 4].longconst);
- (*pos) += 4 + BYTES_TO_EXP_ELEM (temm + 1);
+ int temm = longest_to_int (exp->elts[pc + 3].longconst);
+ (*pos) += 3 + BYTES_TO_EXP_ELEM (temm + 1);
}
else
evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP);
assoc = 0;
fputs_filtered (type_name_no_tag (exp->elts[pc + 1].type), stream);
fputs_filtered ("::", stream);
- nargs = longest_to_int (exp->elts[pc + 3].longconst);
- (*pos) += 5 + BYTES_TO_EXP_ELEM (nargs + 1);
- fputs_filtered (&exp->elts[pc + 4].string, stream);
+ nargs = longest_to_int (exp->elts[pc + 2].longconst);
+ (*pos) += 4 + BYTES_TO_EXP_ELEM (nargs + 1);
+ fputs_filtered (&exp->elts[pc + 3].string, stream);
return;
case OP_LONG:
return;
case OP_FUNCALL:
- (*pos) += 3;
+ (*pos) += 2;
nargs = longest_to_int (exp->elts[pc + 1].longconst);
print_subexp (exp, pos, stream, PREC_SUFFIX);
fputs_filtered (" (", stream);
nargs = longest_to_int (exp->elts[elt].longconst);
fprintf_filtered (stream, "Number of args: %d", nargs);
- elt += 3;
+ elt += 2;
for (i = 1; i <= nargs + 1; i++)
elt = dump_subexp (exp, stream, elt);
type_print (exp->elts[elt].type, NULL, stream, 0);
fprintf_filtered (stream, ") ");
- len = longest_to_int (exp->elts[elt + 2].longconst);
- elem_name = &exp->elts[elt + 3].string;
+ len = longest_to_int (exp->elts[elt + 1].longconst);
+ elem_name = &exp->elts[elt + 2].string;
fprintf_filtered (stream, "Field name: `%.*s'", len, elem_name);
- elt += 5 + BYTES_TO_EXP_ELEM (len + 1);
+ elt += 4 + BYTES_TO_EXP_ELEM (len + 1);
}
break;
default:
OP_INTERNALVAR,
/* OP_FUNCALL is followed by an integer in the next exp_element.
- The integer is the number of args to the function call. That
- many plus one values from following subexpressions are used,
- the first one being the function. Next comes the current
- block: this is used when doing operator overloading in C++.
- Finally, there is a repeat of OP_FUNCALL, making four
- exp_elements. */
+ The integer is the number of args to the function call.
+ That many plus one values from following subexpressions
+ are used, the first one being the function.
+ The integer is followed by a repeat of OP_FUNCALL,
+ making three exp_elements. */
OP_FUNCALL,
/* OP_OBJC_MSGCALL is followed by a string in the next exp_element and then an
and function calls are all exactly the same syntactically. They may
only be dismabiguated at runtime. Thus this operator, which
indicates that we have found something of the form <name> ( <stuff> ) */
-
- /* NOTE: carlton/2003-01-20: Now that I've added a block to
- OP_FUNCALL, it's no longer exactly like OP_FUNCALL. */
OP_F77_UNDETERMINED_ARGLIST,
/* The following OP is a special one, it introduces a F77 complex
/* Objective C: "@selector" pseudo-operator */
OP_OBJC_SELECTOR,
- /* OP_SCOPE surrounds a type name, a block, and a field name. The
- type name and block are encoded as one element, but the field
- name stays as a string, which, of course, is variable
- length. */
+ /* OP_SCOPE surrounds a type name and a field name. The type
+ name is encoded as one element, but the field name stays as
+ a string, which, of course, is variable length. */
OP_SCOPE,
/* Used to represent named structure field values in brace
token.length = dot_index;
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (typ);
- write_exp_elt_block (NULL);
write_exp_string (token);
write_exp_elt_opcode (OP_SCOPE);
if (dot_index < name.length)
arglist ')' %prec DOT
{ write_exp_elt_opcode (OP_FUNCALL);
write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_block (expression_context_block);
write_exp_elt_opcode (OP_FUNCALL); }
;
arglist ')' %prec ARROW
{ write_exp_elt_opcode (OP_FUNCALL);
write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_block (expression_context_block);
write_exp_elt_opcode (OP_FUNCALL); }
;
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (type);
- write_exp_elt_block (NULL);
write_exp_string ($3);
write_exp_elt_opcode (OP_SCOPE);
}
tmp_token.ptr[tmp_token.length] = 0;
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (type);
- write_exp_elt_block (NULL);
write_exp_string (tmp_token);
write_exp_elt_opcode (OP_SCOPE);
}
arglist ')' %prec ARROW
{ write_exp_elt_opcode (OP_FUNCALL);
write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_block (expression_context_block);
write_exp_elt_opcode (OP_FUNCALL);
pop_current_type (); }
;
write_exp_elt_opcode (OP_SCOPE);
write_exp_elt_type (type);
- write_exp_elt_block (NULL);
write_exp_string ($3);
write_exp_elt_opcode (OP_SCOPE);
}
/* C++ */
case OP_SCOPE:
oplen = longest_to_int (expr->elts[endpos - 2].longconst);
- oplen = 6 + BYTES_TO_EXP_ELEM (oplen + 1);
+ oplen = 5 + BYTES_TO_EXP_ELEM (oplen + 1);
break;
case OP_LONG:
break;
case OP_FUNCALL:
- oplen = 4;
- args = 1 + longest_to_int (expr->elts[endpos - 3].longconst);
- break;
-
case OP_F77_UNDETERMINED_ARGLIST:
oplen = 3;
args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
/* C++ */
case OP_SCOPE:
oplen = longest_to_int (inexpr->elts[inend - 2].longconst);
- oplen = 6 + BYTES_TO_EXP_ELEM (oplen + 1);
+ oplen = 5 + BYTES_TO_EXP_ELEM (oplen + 1);
break;
case OP_LONG:
break;
case OP_FUNCALL:
- oplen = 4;
- args = 1 + longest_to_int (inexpr->elts[inend - 3].longconst);
- break;
-
case OP_F77_UNDETERMINED_ARGLIST:
oplen = 3;
args = 1 + longest_to_int (inexpr->elts[inend - 2].longconst);
int, int *, struct type *);
static int find_oload_champ_namespace (struct type **arg_types, int nargs,
- const struct block *current_block,
const char *func_name,
const char *qualified_name,
struct symbol ***oload_syms,
static
int find_oload_champ_namespace_loop (struct type **arg_types, int nargs,
- const struct block *current_block,
const char *func_name,
const char *qualified_name,
int namespace_len,
struct type *curtype,
const char *name,
struct type *intype,
- const struct block *
- block,
enum noside noside);
static struct value *value_namespace_elt (const struct type *curtype,
- const struct block *block,
const char *name,
enum noside noside);
static struct value *value_maybe_namespace_elt (const struct type *curtype,
- const struct block *block,
const char *name,
enum noside noside);
int
find_overload_match (struct type **arg_types, int nargs, char *name, int method,
int lax, struct value **objp, struct symbol *fsym,
- const struct block *current_block,
struct value **valp, struct symbol **symp, int *staticp)
{
struct value *obj = (objp ? *objp : NULL);
make_cleanup (xfree, oload_champ_bv);
oload_champ = find_oload_champ_namespace (arg_types, nargs,
- current_block,
func_name,
qualified_name,
&oload_syms,
static int
find_oload_champ_namespace (struct type **arg_types, int nargs,
- const struct block *current_block,
const char *func_name,
const char *qualified_name,
struct symbol ***oload_syms,
int oload_champ;
find_oload_champ_namespace_loop (arg_types, nargs,
- current_block, func_name,
+ func_name,
qualified_name, 0,
oload_syms, oload_champ_bv,
&oload_champ);
static int
find_oload_champ_namespace_loop (struct type **arg_types, int nargs,
- const struct block *current_block,
const char *func_name,
const char *qualified_name,
int namespace_len,
{
searched_deeper = 1;
- if (find_oload_champ_namespace_loop (arg_types, nargs, current_block,
+ if (find_oload_champ_namespace_loop (arg_types, nargs,
func_name, qualified_name,
next_namespace_len,
oload_syms, oload_champ_bv,
strncpy (new_namespace, qualified_name, namespace_len);
new_namespace[namespace_len] = '\0';
new_oload_syms = make_symbol_overload_list (func_name,
- new_namespace,
- current_block);
+ new_namespace);
while (new_oload_syms[num_fns])
++num_fns;
}
/* C++: Given an aggregate type CURTYPE, and a member name NAME,
- return the appropriate member. BLOCK is the current block; it is
- used if TYPE is a namespace. This function is used to resolve user
- expressions of the form "DOMAIN::NAME". For more details on what
- happens, see the comment before value_struct_elt_for_reference. */
+ return the appropriate member. This function is used to resolve
+ user expressions of the form "DOMAIN::NAME". For more details on
+ what happens, see the comment before
+ value_struct_elt_for_reference. */
struct value *
value_aggregate_elt (struct type *curtype,
- const struct block *block,
const char *name,
enum noside noside)
{
case TYPE_CODE_STRUCT:
case TYPE_CODE_UNION:
return value_struct_elt_for_reference (curtype, 0, curtype, name, NULL,
- block, noside);
+ noside);
case TYPE_CODE_NAMESPACE:
- return value_namespace_elt (curtype, block, name, noside);
+ return value_namespace_elt (curtype, name, noside);
default:
error ("Internal error: non-aggregate type to value_aggregate_elt");
}
value_struct_elt_for_reference (struct type *domain, int offset,
struct type *curtype, const char *name,
struct type *intype,
- const struct block *block,
enum noside noside)
{
struct type *t = curtype;
TYPE_BASECLASS (t, i),
name,
intype,
- block,
noside);
if (v)
return v;
/* As a last chance, look it up using lookup_symbol_namespace: this
works for types. */
- return value_maybe_namespace_elt (curtype, block, name, noside);
+ return value_maybe_namespace_elt (curtype, name, noside);
}
/* C++: Return the member NAME of the namespace given by the type
- CURTYPE. Look this up within BLOCK: in particular, apply the using
- directives from within BLOCK. */
+ CURTYPE. */
static struct value *
value_namespace_elt (const struct type *curtype,
- const struct block *block,
const char *name,
enum noside noside)
{
- struct value *retval = value_maybe_namespace_elt (curtype, block, name,
+ struct value *retval = value_maybe_namespace_elt (curtype, name,
noside);
if (retval == NULL)
static struct value *
value_maybe_namespace_elt (const struct type *curtype,
- const struct block *block,
const char *name,
enum noside noside)
{
const struct symbol *sym;
sym = cp_lookup_symbol_namespace (namespace_name, name, NULL,
- block, VAR_DOMAIN, NULL);
+ get_selected_block (0), VAR_DOMAIN,
+ NULL);
if (sym == NULL)
return NULL;
&& (SYMBOL_CLASS (sym) == LOC_TYPEDEF))
return allocate_value (SYMBOL_TYPE (sym));
else
- return value_of_variable (sym, block);
+ return value_of_variable (sym, get_selected_block (0));
}
/* Given a pointer value V, find the real (RTTI) type
char *err);
extern struct value *value_aggregate_elt (struct type *curtype,
- const struct block *block,
const char *name,
enum noside noside);
extern int find_overload_match (struct type **arg_types, int nargs,
char *name, int method, int lax,
struct value **objp, struct symbol *fsym,
- const struct block *current_block,
struct value **valp, struct symbol **symp,
int *staticp);