1e93f7393Sniklas /* Parse expressions for GDB.
2*63addd46Skettenis
3*63addd46Skettenis Copyright 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
4*63addd46Skettenis 1997, 1998, 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
5*63addd46Skettenis
6e93f7393Sniklas Modified from expread.y by the Department of Computer Science at the
7e93f7393Sniklas State University of New York at Buffalo, 1991.
8e93f7393Sniklas
9e93f7393Sniklas This file is part of GDB.
10e93f7393Sniklas
11e93f7393Sniklas This program is free software; you can redistribute it and/or modify
12e93f7393Sniklas it under the terms of the GNU General Public License as published by
13e93f7393Sniklas the Free Software Foundation; either version 2 of the License, or
14e93f7393Sniklas (at your option) any later version.
15e93f7393Sniklas
16e93f7393Sniklas This program is distributed in the hope that it will be useful,
17e93f7393Sniklas but WITHOUT ANY WARRANTY; without even the implied warranty of
18e93f7393Sniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19e93f7393Sniklas GNU General Public License for more details.
20e93f7393Sniklas
21e93f7393Sniklas You should have received a copy of the GNU General Public License
22e93f7393Sniklas along with this program; if not, write to the Free Software
23b725ae77Skettenis Foundation, Inc., 59 Temple Place - Suite 330,
24b725ae77Skettenis Boston, MA 02111-1307, USA. */
25e93f7393Sniklas
26e93f7393Sniklas /* Parse an expression from text in a string,
27e93f7393Sniklas and return the result as a struct expression pointer.
28e93f7393Sniklas That structure contains arithmetic operations in reverse polish,
29e93f7393Sniklas with constants represented by operations that are followed by special data.
30e93f7393Sniklas See expression.h for the details of the format.
31e93f7393Sniklas What is important here is that it can be built up sequentially
32e93f7393Sniklas during the process of parsing; the lower levels of the tree always
33e93f7393Sniklas come first in the result. */
34e93f7393Sniklas
35b725ae77Skettenis #include <ctype.h>
36b725ae77Skettenis
37e93f7393Sniklas #include "defs.h"
38e93f7393Sniklas #include "gdb_string.h"
39e93f7393Sniklas #include "symtab.h"
40e93f7393Sniklas #include "gdbtypes.h"
41e93f7393Sniklas #include "frame.h"
42e93f7393Sniklas #include "expression.h"
43e93f7393Sniklas #include "value.h"
44e93f7393Sniklas #include "command.h"
45e93f7393Sniklas #include "language.h"
46e93f7393Sniklas #include "parser-defs.h"
47b725ae77Skettenis #include "gdbcmd.h"
48b725ae77Skettenis #include "symfile.h" /* for overlay functions */
49b725ae77Skettenis #include "inferior.h" /* for NUM_PSEUDO_REGS. NOTE: replace
50b725ae77Skettenis with "gdbarch.h" when appropriate. */
51b725ae77Skettenis #include "doublest.h"
52b725ae77Skettenis #include "gdb_assert.h"
53b725ae77Skettenis #include "block.h"
54b725ae77Skettenis
55b725ae77Skettenis /* Standard set of definitions for printing, dumping, prefixifying,
56b725ae77Skettenis * and evaluating expressions. */
57b725ae77Skettenis
58b725ae77Skettenis const struct exp_descriptor exp_descriptor_standard =
59b725ae77Skettenis {
60b725ae77Skettenis print_subexp_standard,
61b725ae77Skettenis operator_length_standard,
62b725ae77Skettenis op_name_standard,
63b725ae77Skettenis dump_subexp_body_standard,
64b725ae77Skettenis evaluate_subexp_standard
65b725ae77Skettenis };
66b725ae77Skettenis
67b725ae77Skettenis /* Symbols which architectures can redefine. */
68b725ae77Skettenis
69b725ae77Skettenis /* Some systems have routines whose names start with `$'. Giving this
70b725ae77Skettenis macro a non-zero value tells GDB's expression parser to check for
71b725ae77Skettenis such routines when parsing tokens that begin with `$'.
72b725ae77Skettenis
73b725ae77Skettenis On HP-UX, certain system routines (millicode) have names beginning
74b725ae77Skettenis with `$' or `$$'. For example, `$$dyncall' is a millicode routine
75b725ae77Skettenis that handles inter-space procedure calls on PA-RISC. */
76b725ae77Skettenis #ifndef SYMBOLS_CAN_START_WITH_DOLLAR
77b725ae77Skettenis #define SYMBOLS_CAN_START_WITH_DOLLAR (0)
78b725ae77Skettenis #endif
79b725ae77Skettenis
80b725ae77Skettenis
81e93f7393Sniklas
82e93f7393Sniklas /* Global variables declared in parser-defs.h (and commented there). */
83e93f7393Sniklas struct expression *expout;
84e93f7393Sniklas int expout_size;
85e93f7393Sniklas int expout_ptr;
86e93f7393Sniklas struct block *expression_context_block;
87b725ae77Skettenis CORE_ADDR expression_context_pc;
88e93f7393Sniklas struct block *innermost_block;
89e93f7393Sniklas int arglist_len;
90e93f7393Sniklas union type_stack_elt *type_stack;
91e93f7393Sniklas int type_stack_depth, type_stack_size;
92e93f7393Sniklas char *lexptr;
93b725ae77Skettenis char *prev_lexptr;
94e93f7393Sniklas char *namecopy;
95e93f7393Sniklas int paren_depth;
96e93f7393Sniklas int comma_terminates;
97e93f7393Sniklas
98b725ae77Skettenis static int expressiondebug = 0;
99e93f7393Sniklas
100b725ae77Skettenis static void free_funcalls (void *ignore);
101e93f7393Sniklas
102b725ae77Skettenis static void prefixify_expression (struct expression *);
103b725ae77Skettenis
104b725ae77Skettenis static void prefixify_subexp (struct expression *, struct expression *, int,
105b725ae77Skettenis int);
106b725ae77Skettenis
107*63addd46Skettenis static struct expression *parse_exp_in_context (char **, struct block *, int,
108*63addd46Skettenis int);
109*63addd46Skettenis
110b725ae77Skettenis void _initialize_parse (void);
111e93f7393Sniklas
112e93f7393Sniklas /* Data structure for saving values of arglist_len for function calls whose
113e93f7393Sniklas arguments contain other function calls. */
114e93f7393Sniklas
115e93f7393Sniklas struct funcall
116e93f7393Sniklas {
117e93f7393Sniklas struct funcall *next;
118e93f7393Sniklas int arglist_len;
119e93f7393Sniklas };
120e93f7393Sniklas
121e93f7393Sniklas static struct funcall *funcall_chain;
122e93f7393Sniklas
123e93f7393Sniklas /* Begin counting arguments for a function call,
124e93f7393Sniklas saving the data about any containing call. */
125e93f7393Sniklas
126e93f7393Sniklas void
start_arglist(void)127b725ae77Skettenis start_arglist (void)
128e93f7393Sniklas {
129b725ae77Skettenis struct funcall *new;
130e93f7393Sniklas
131e93f7393Sniklas new = (struct funcall *) xmalloc (sizeof (struct funcall));
132e93f7393Sniklas new->next = funcall_chain;
133e93f7393Sniklas new->arglist_len = arglist_len;
134e93f7393Sniklas arglist_len = 0;
135e93f7393Sniklas funcall_chain = new;
136e93f7393Sniklas }
137e93f7393Sniklas
138e93f7393Sniklas /* Return the number of arguments in a function call just terminated,
139e93f7393Sniklas and restore the data for the containing function call. */
140e93f7393Sniklas
141e93f7393Sniklas int
end_arglist(void)142b725ae77Skettenis end_arglist (void)
143e93f7393Sniklas {
144b725ae77Skettenis int val = arglist_len;
145b725ae77Skettenis struct funcall *call = funcall_chain;
146e93f7393Sniklas funcall_chain = call->next;
147e93f7393Sniklas arglist_len = call->arglist_len;
148b725ae77Skettenis xfree (call);
149e93f7393Sniklas return val;
150e93f7393Sniklas }
151e93f7393Sniklas
152e93f7393Sniklas /* Free everything in the funcall chain.
153e93f7393Sniklas Used when there is an error inside parsing. */
154e93f7393Sniklas
155e93f7393Sniklas static void
free_funcalls(void * ignore)156b725ae77Skettenis free_funcalls (void *ignore)
157e93f7393Sniklas {
158b725ae77Skettenis struct funcall *call, *next;
159e93f7393Sniklas
160e93f7393Sniklas for (call = funcall_chain; call; call = next)
161e93f7393Sniklas {
162e93f7393Sniklas next = call->next;
163b725ae77Skettenis xfree (call);
164e93f7393Sniklas }
165e93f7393Sniklas }
166e93f7393Sniklas
167e93f7393Sniklas /* This page contains the functions for adding data to the struct expression
168e93f7393Sniklas being constructed. */
169e93f7393Sniklas
170e93f7393Sniklas /* Add one element to the end of the expression. */
171e93f7393Sniklas
172e93f7393Sniklas /* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
173e93f7393Sniklas a register through here */
174e93f7393Sniklas
175e93f7393Sniklas void
write_exp_elt(union exp_element expelt)176b725ae77Skettenis write_exp_elt (union exp_element expelt)
177e93f7393Sniklas {
178e93f7393Sniklas if (expout_ptr >= expout_size)
179e93f7393Sniklas {
180e93f7393Sniklas expout_size *= 2;
181e93f7393Sniklas expout = (struct expression *)
182e93f7393Sniklas xrealloc ((char *) expout, sizeof (struct expression)
183e93f7393Sniklas + EXP_ELEM_TO_BYTES (expout_size));
184e93f7393Sniklas }
185e93f7393Sniklas expout->elts[expout_ptr++] = expelt;
186e93f7393Sniklas }
187e93f7393Sniklas
188e93f7393Sniklas void
write_exp_elt_opcode(enum exp_opcode expelt)189b725ae77Skettenis write_exp_elt_opcode (enum exp_opcode expelt)
190e93f7393Sniklas {
191e93f7393Sniklas union exp_element tmp;
192e93f7393Sniklas
193e93f7393Sniklas tmp.opcode = expelt;
194e93f7393Sniklas
195e93f7393Sniklas write_exp_elt (tmp);
196e93f7393Sniklas }
197e93f7393Sniklas
198e93f7393Sniklas void
write_exp_elt_sym(struct symbol * expelt)199b725ae77Skettenis write_exp_elt_sym (struct symbol *expelt)
200e93f7393Sniklas {
201e93f7393Sniklas union exp_element tmp;
202e93f7393Sniklas
203e93f7393Sniklas tmp.symbol = expelt;
204e93f7393Sniklas
205e93f7393Sniklas write_exp_elt (tmp);
206e93f7393Sniklas }
207e93f7393Sniklas
208e93f7393Sniklas void
write_exp_elt_block(struct block * b)209b725ae77Skettenis write_exp_elt_block (struct block *b)
210e93f7393Sniklas {
211e93f7393Sniklas union exp_element tmp;
212e93f7393Sniklas tmp.block = b;
213e93f7393Sniklas write_exp_elt (tmp);
214e93f7393Sniklas }
215e93f7393Sniklas
216e93f7393Sniklas void
write_exp_elt_longcst(LONGEST expelt)217b725ae77Skettenis write_exp_elt_longcst (LONGEST expelt)
218e93f7393Sniklas {
219e93f7393Sniklas union exp_element tmp;
220e93f7393Sniklas
221e93f7393Sniklas tmp.longconst = expelt;
222e93f7393Sniklas
223e93f7393Sniklas write_exp_elt (tmp);
224e93f7393Sniklas }
225e93f7393Sniklas
226e93f7393Sniklas void
write_exp_elt_dblcst(DOUBLEST expelt)227b725ae77Skettenis write_exp_elt_dblcst (DOUBLEST expelt)
228e93f7393Sniklas {
229e93f7393Sniklas union exp_element tmp;
230e93f7393Sniklas
231e93f7393Sniklas tmp.doubleconst = expelt;
232e93f7393Sniklas
233e93f7393Sniklas write_exp_elt (tmp);
234e93f7393Sniklas }
235e93f7393Sniklas
236e93f7393Sniklas void
write_exp_elt_type(struct type * expelt)237b725ae77Skettenis write_exp_elt_type (struct type *expelt)
238e93f7393Sniklas {
239e93f7393Sniklas union exp_element tmp;
240e93f7393Sniklas
241e93f7393Sniklas tmp.type = expelt;
242e93f7393Sniklas
243e93f7393Sniklas write_exp_elt (tmp);
244e93f7393Sniklas }
245e93f7393Sniklas
246e93f7393Sniklas void
write_exp_elt_intern(struct internalvar * expelt)247b725ae77Skettenis write_exp_elt_intern (struct internalvar *expelt)
248e93f7393Sniklas {
249e93f7393Sniklas union exp_element tmp;
250e93f7393Sniklas
251e93f7393Sniklas tmp.internalvar = expelt;
252e93f7393Sniklas
253e93f7393Sniklas write_exp_elt (tmp);
254e93f7393Sniklas }
255e93f7393Sniklas
256e93f7393Sniklas /* Add a string constant to the end of the expression.
257e93f7393Sniklas
258e93f7393Sniklas String constants are stored by first writing an expression element
259e93f7393Sniklas that contains the length of the string, then stuffing the string
260e93f7393Sniklas constant itself into however many expression elements are needed
261e93f7393Sniklas to hold it, and then writing another expression element that contains
262e93f7393Sniklas the length of the string. I.E. an expression element at each end of
263e93f7393Sniklas the string records the string length, so you can skip over the
264e93f7393Sniklas expression elements containing the actual string bytes from either
265e93f7393Sniklas end of the string. Note that this also allows gdb to handle
266e93f7393Sniklas strings with embedded null bytes, as is required for some languages.
267e93f7393Sniklas
268e93f7393Sniklas Don't be fooled by the fact that the string is null byte terminated,
269e93f7393Sniklas this is strictly for the convenience of debugging gdb itself. Gdb
270e93f7393Sniklas Gdb does not depend up the string being null terminated, since the
271e93f7393Sniklas actual length is recorded in expression elements at each end of the
272e93f7393Sniklas string. The null byte is taken into consideration when computing how
273e93f7393Sniklas many expression elements are required to hold the string constant, of
274e93f7393Sniklas course. */
275e93f7393Sniklas
276e93f7393Sniklas
277e93f7393Sniklas void
write_exp_string(struct stoken str)278b725ae77Skettenis write_exp_string (struct stoken str)
279e93f7393Sniklas {
280b725ae77Skettenis int len = str.length;
281b725ae77Skettenis int lenelt;
282b725ae77Skettenis char *strdata;
283e93f7393Sniklas
284e93f7393Sniklas /* Compute the number of expression elements required to hold the string
285e93f7393Sniklas (including a null byte terminator), along with one expression element
286e93f7393Sniklas at each end to record the actual string length (not including the
287e93f7393Sniklas null byte terminator). */
288e93f7393Sniklas
289e93f7393Sniklas lenelt = 2 + BYTES_TO_EXP_ELEM (len + 1);
290e93f7393Sniklas
291e93f7393Sniklas /* Ensure that we have enough available expression elements to store
292e93f7393Sniklas everything. */
293e93f7393Sniklas
294e93f7393Sniklas if ((expout_ptr + lenelt) >= expout_size)
295e93f7393Sniklas {
296e93f7393Sniklas expout_size = max (expout_size * 2, expout_ptr + lenelt + 10);
297e93f7393Sniklas expout = (struct expression *)
298e93f7393Sniklas xrealloc ((char *) expout, (sizeof (struct expression)
299e93f7393Sniklas + EXP_ELEM_TO_BYTES (expout_size)));
300e93f7393Sniklas }
301e93f7393Sniklas
302e93f7393Sniklas /* Write the leading length expression element (which advances the current
303e93f7393Sniklas expression element index), then write the string constant followed by a
304e93f7393Sniklas terminating null byte, and then write the trailing length expression
305e93f7393Sniklas element. */
306e93f7393Sniklas
307e93f7393Sniklas write_exp_elt_longcst ((LONGEST) len);
308e93f7393Sniklas strdata = (char *) &expout->elts[expout_ptr];
309e93f7393Sniklas memcpy (strdata, str.ptr, len);
310e93f7393Sniklas *(strdata + len) = '\0';
311e93f7393Sniklas expout_ptr += lenelt - 2;
312e93f7393Sniklas write_exp_elt_longcst ((LONGEST) len);
313e93f7393Sniklas }
314e93f7393Sniklas
315e93f7393Sniklas /* Add a bitstring constant to the end of the expression.
316e93f7393Sniklas
317e93f7393Sniklas Bitstring constants are stored by first writing an expression element
318e93f7393Sniklas that contains the length of the bitstring (in bits), then stuffing the
319e93f7393Sniklas bitstring constant itself into however many expression elements are
320e93f7393Sniklas needed to hold it, and then writing another expression element that
321e93f7393Sniklas contains the length of the bitstring. I.E. an expression element at
322e93f7393Sniklas each end of the bitstring records the bitstring length, so you can skip
323e93f7393Sniklas over the expression elements containing the actual bitstring bytes from
324e93f7393Sniklas either end of the bitstring. */
325e93f7393Sniklas
326e93f7393Sniklas void
write_exp_bitstring(struct stoken str)327b725ae77Skettenis write_exp_bitstring (struct stoken str)
328e93f7393Sniklas {
329b725ae77Skettenis int bits = str.length; /* length in bits */
330b725ae77Skettenis int len = (bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
331b725ae77Skettenis int lenelt;
332b725ae77Skettenis char *strdata;
333e93f7393Sniklas
334e93f7393Sniklas /* Compute the number of expression elements required to hold the bitstring,
335e93f7393Sniklas along with one expression element at each end to record the actual
336e93f7393Sniklas bitstring length in bits. */
337e93f7393Sniklas
338e93f7393Sniklas lenelt = 2 + BYTES_TO_EXP_ELEM (len);
339e93f7393Sniklas
340e93f7393Sniklas /* Ensure that we have enough available expression elements to store
341e93f7393Sniklas everything. */
342e93f7393Sniklas
343e93f7393Sniklas if ((expout_ptr + lenelt) >= expout_size)
344e93f7393Sniklas {
345e93f7393Sniklas expout_size = max (expout_size * 2, expout_ptr + lenelt + 10);
346e93f7393Sniklas expout = (struct expression *)
347e93f7393Sniklas xrealloc ((char *) expout, (sizeof (struct expression)
348e93f7393Sniklas + EXP_ELEM_TO_BYTES (expout_size)));
349e93f7393Sniklas }
350e93f7393Sniklas
351e93f7393Sniklas /* Write the leading length expression element (which advances the current
352e93f7393Sniklas expression element index), then write the bitstring constant, and then
353e93f7393Sniklas write the trailing length expression element. */
354e93f7393Sniklas
355e93f7393Sniklas write_exp_elt_longcst ((LONGEST) bits);
356e93f7393Sniklas strdata = (char *) &expout->elts[expout_ptr];
357e93f7393Sniklas memcpy (strdata, str.ptr, len);
358e93f7393Sniklas expout_ptr += lenelt - 2;
359e93f7393Sniklas write_exp_elt_longcst ((LONGEST) bits);
360e93f7393Sniklas }
361e93f7393Sniklas
362e93f7393Sniklas /* Add the appropriate elements for a minimal symbol to the end of
363e93f7393Sniklas the expression. The rationale behind passing in text_symbol_type and
364e93f7393Sniklas data_symbol_type was so that Modula-2 could pass in WORD for
365e93f7393Sniklas data_symbol_type. Perhaps it still is useful to have those types vary
366e93f7393Sniklas based on the language, but they no longer have names like "int", so
367e93f7393Sniklas the initial rationale is gone. */
368e93f7393Sniklas
369e93f7393Sniklas static struct type *msym_text_symbol_type;
370e93f7393Sniklas static struct type *msym_data_symbol_type;
371e93f7393Sniklas static struct type *msym_unknown_symbol_type;
372e93f7393Sniklas
373e93f7393Sniklas void
write_exp_msymbol(struct minimal_symbol * msymbol,struct type * text_symbol_type,struct type * data_symbol_type)374b725ae77Skettenis write_exp_msymbol (struct minimal_symbol *msymbol,
375b725ae77Skettenis struct type *text_symbol_type,
376b725ae77Skettenis struct type *data_symbol_type)
377e93f7393Sniklas {
378b725ae77Skettenis CORE_ADDR addr;
379b725ae77Skettenis
380e93f7393Sniklas write_exp_elt_opcode (OP_LONG);
381b725ae77Skettenis /* Let's make the type big enough to hold a 64-bit address. */
382b725ae77Skettenis write_exp_elt_type (builtin_type_CORE_ADDR);
383b725ae77Skettenis
384b725ae77Skettenis addr = SYMBOL_VALUE_ADDRESS (msymbol);
385b725ae77Skettenis if (overlay_debugging)
386b725ae77Skettenis addr = symbol_overlayed_address (addr, SYMBOL_BFD_SECTION (msymbol));
387b725ae77Skettenis write_exp_elt_longcst ((LONGEST) addr);
388b725ae77Skettenis
389e93f7393Sniklas write_exp_elt_opcode (OP_LONG);
390e93f7393Sniklas
391e93f7393Sniklas write_exp_elt_opcode (UNOP_MEMVAL);
392e93f7393Sniklas switch (msymbol->type)
393e93f7393Sniklas {
394e93f7393Sniklas case mst_text:
395e93f7393Sniklas case mst_file_text:
396e93f7393Sniklas case mst_solib_trampoline:
397e93f7393Sniklas write_exp_elt_type (msym_text_symbol_type);
398e93f7393Sniklas break;
399e93f7393Sniklas
400e93f7393Sniklas case mst_data:
401e93f7393Sniklas case mst_file_data:
402e93f7393Sniklas case mst_bss:
403e93f7393Sniklas case mst_file_bss:
404e93f7393Sniklas write_exp_elt_type (msym_data_symbol_type);
405e93f7393Sniklas break;
406e93f7393Sniklas
407e93f7393Sniklas default:
408e93f7393Sniklas write_exp_elt_type (msym_unknown_symbol_type);
409e93f7393Sniklas break;
410e93f7393Sniklas }
411e93f7393Sniklas write_exp_elt_opcode (UNOP_MEMVAL);
412e93f7393Sniklas }
413e93f7393Sniklas
414e93f7393Sniklas /* Recognize tokens that start with '$'. These include:
415e93f7393Sniklas
416e93f7393Sniklas $regname A native register name or a "standard
417e93f7393Sniklas register name".
418e93f7393Sniklas
419e93f7393Sniklas $variable A convenience variable with a name chosen
420e93f7393Sniklas by the user.
421e93f7393Sniklas
422e93f7393Sniklas $digits Value history with index <digits>, starting
423e93f7393Sniklas from the first value which has index 1.
424e93f7393Sniklas
425e93f7393Sniklas $$digits Value history with index <digits> relative
426e93f7393Sniklas to the last value. I.E. $$0 is the last
427e93f7393Sniklas value, $$1 is the one previous to that, $$2
428e93f7393Sniklas is the one previous to $$1, etc.
429e93f7393Sniklas
430e93f7393Sniklas $ | $0 | $$0 The last value in the value history.
431e93f7393Sniklas
432e93f7393Sniklas $$ An abbreviation for the second to the last
433e93f7393Sniklas value in the value history, I.E. $$1
434e93f7393Sniklas
435e93f7393Sniklas */
436e93f7393Sniklas
437e93f7393Sniklas void
write_dollar_variable(struct stoken str)438b725ae77Skettenis write_dollar_variable (struct stoken str)
439e93f7393Sniklas {
440e93f7393Sniklas /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
441e93f7393Sniklas and $$digits (equivalent to $<-digits> if you could type that). */
442e93f7393Sniklas
443e93f7393Sniklas int negate = 0;
444e93f7393Sniklas int i = 1;
445e93f7393Sniklas /* Double dollar means negate the number and add -1 as well.
446e93f7393Sniklas Thus $$ alone means -1. */
447e93f7393Sniklas if (str.length >= 2 && str.ptr[1] == '$')
448e93f7393Sniklas {
449e93f7393Sniklas negate = 1;
450e93f7393Sniklas i = 2;
451e93f7393Sniklas }
452e93f7393Sniklas if (i == str.length)
453e93f7393Sniklas {
454e93f7393Sniklas /* Just dollars (one or two) */
455e93f7393Sniklas i = -negate;
456e93f7393Sniklas goto handle_last;
457e93f7393Sniklas }
458e93f7393Sniklas /* Is the rest of the token digits? */
459e93f7393Sniklas for (; i < str.length; i++)
460e93f7393Sniklas if (!(str.ptr[i] >= '0' && str.ptr[i] <= '9'))
461e93f7393Sniklas break;
462e93f7393Sniklas if (i == str.length)
463e93f7393Sniklas {
464e93f7393Sniklas i = atoi (str.ptr + 1 + negate);
465e93f7393Sniklas if (negate)
466e93f7393Sniklas i = -i;
467e93f7393Sniklas goto handle_last;
468e93f7393Sniklas }
469e93f7393Sniklas
470e93f7393Sniklas /* Handle tokens that refer to machine registers:
471e93f7393Sniklas $ followed by a register name. */
472b725ae77Skettenis i = frame_map_name_to_regnum (deprecated_selected_frame,
473b725ae77Skettenis str.ptr + 1, str.length - 1);
474b725ae77Skettenis if (i >= 0)
475e93f7393Sniklas goto handle_register;
476b725ae77Skettenis
477b725ae77Skettenis if (SYMBOLS_CAN_START_WITH_DOLLAR)
478b725ae77Skettenis {
479b725ae77Skettenis struct symbol *sym = NULL;
480b725ae77Skettenis struct minimal_symbol *msym = NULL;
481b725ae77Skettenis
482b725ae77Skettenis /* On HP-UX, certain system routines (millicode) have names beginning
483b725ae77Skettenis with $ or $$, e.g. $$dyncall, which handles inter-space procedure
484b725ae77Skettenis calls on PA-RISC. Check for those, first. */
485b725ae77Skettenis
486b725ae77Skettenis /* This code is not enabled on non HP-UX systems, since worst case
487b725ae77Skettenis symbol table lookup performance is awful, to put it mildly. */
488b725ae77Skettenis
489b725ae77Skettenis sym = lookup_symbol (copy_name (str), (struct block *) NULL,
490b725ae77Skettenis VAR_DOMAIN, (int *) NULL, (struct symtab **) NULL);
491b725ae77Skettenis if (sym)
492b725ae77Skettenis {
493b725ae77Skettenis write_exp_elt_opcode (OP_VAR_VALUE);
494b725ae77Skettenis write_exp_elt_block (block_found); /* set by lookup_symbol */
495b725ae77Skettenis write_exp_elt_sym (sym);
496b725ae77Skettenis write_exp_elt_opcode (OP_VAR_VALUE);
497b725ae77Skettenis return;
498e93f7393Sniklas }
499b725ae77Skettenis msym = lookup_minimal_symbol (copy_name (str), NULL, NULL);
500b725ae77Skettenis if (msym)
501e93f7393Sniklas {
502b725ae77Skettenis write_exp_msymbol (msym,
503b725ae77Skettenis lookup_function_type (builtin_type_int),
504b725ae77Skettenis builtin_type_int);
505b725ae77Skettenis return;
506b725ae77Skettenis }
507e93f7393Sniklas }
508e93f7393Sniklas
509e93f7393Sniklas /* Any other names starting in $ are debugger internal variables. */
510e93f7393Sniklas
511e93f7393Sniklas write_exp_elt_opcode (OP_INTERNALVAR);
512e93f7393Sniklas write_exp_elt_intern (lookup_internalvar (copy_name (str) + 1));
513e93f7393Sniklas write_exp_elt_opcode (OP_INTERNALVAR);
514e93f7393Sniklas return;
515e93f7393Sniklas handle_last:
516e93f7393Sniklas write_exp_elt_opcode (OP_LAST);
517e93f7393Sniklas write_exp_elt_longcst ((LONGEST) i);
518e93f7393Sniklas write_exp_elt_opcode (OP_LAST);
519e93f7393Sniklas return;
520e93f7393Sniklas handle_register:
521e93f7393Sniklas write_exp_elt_opcode (OP_REGISTER);
522e93f7393Sniklas write_exp_elt_longcst (i);
523e93f7393Sniklas write_exp_elt_opcode (OP_REGISTER);
524e93f7393Sniklas return;
525e93f7393Sniklas }
526b725ae77Skettenis
527b725ae77Skettenis
528b725ae77Skettenis /* Parse a string that is possibly a namespace / nested class
529b725ae77Skettenis specification, i.e., something of the form A::B::C::x. Input
530b725ae77Skettenis (NAME) is the entire string; LEN is the current valid length; the
531b725ae77Skettenis output is a string, TOKEN, which points to the largest recognized
532b725ae77Skettenis prefix which is a series of namespaces or classes. CLASS_PREFIX is
533b725ae77Skettenis another output, which records whether a nested class spec was
534b725ae77Skettenis recognized (= 1) or a fully qualified variable name was found (=
535b725ae77Skettenis 0). ARGPTR is side-effected (if non-NULL) to point to beyond the
536b725ae77Skettenis string recognized and consumed by this routine.
537b725ae77Skettenis
538b725ae77Skettenis The return value is a pointer to the symbol for the base class or
539b725ae77Skettenis variable if found, or NULL if not found. Callers must check this
540b725ae77Skettenis first -- if NULL, the outputs may not be correct.
541b725ae77Skettenis
542b725ae77Skettenis This function is used c-exp.y. This is used specifically to get
543b725ae77Skettenis around HP aCC (and possibly other compilers), which insists on
544b725ae77Skettenis generating names with embedded colons for namespace or nested class
545b725ae77Skettenis members.
546b725ae77Skettenis
547b725ae77Skettenis (Argument LEN is currently unused. 1997-08-27)
548b725ae77Skettenis
549b725ae77Skettenis Callers must free memory allocated for the output string TOKEN. */
550b725ae77Skettenis
551b725ae77Skettenis static const char coloncolon[2] =
552b725ae77Skettenis {':', ':'};
553b725ae77Skettenis
554b725ae77Skettenis struct symbol *
parse_nested_classes_for_hpacc(char * name,int len,char ** token,int * class_prefix,char ** argptr)555b725ae77Skettenis parse_nested_classes_for_hpacc (char *name, int len, char **token,
556b725ae77Skettenis int *class_prefix, char **argptr)
557b725ae77Skettenis {
558b725ae77Skettenis /* Comment below comes from decode_line_1 which has very similar
559b725ae77Skettenis code, which is called for "break" command parsing. */
560b725ae77Skettenis
561b725ae77Skettenis /* We have what looks like a class or namespace
562b725ae77Skettenis scope specification (A::B), possibly with many
563b725ae77Skettenis levels of namespaces or classes (A::B::C::D).
564b725ae77Skettenis
565b725ae77Skettenis Some versions of the HP ANSI C++ compiler (as also possibly
566b725ae77Skettenis other compilers) generate class/function/member names with
567b725ae77Skettenis embedded double-colons if they are inside namespaces. To
568b725ae77Skettenis handle this, we loop a few times, considering larger and
569b725ae77Skettenis larger prefixes of the string as though they were single
570b725ae77Skettenis symbols. So, if the initially supplied string is
571b725ae77Skettenis A::B::C::D::foo, we have to look up "A", then "A::B",
572b725ae77Skettenis then "A::B::C", then "A::B::C::D", and finally
573b725ae77Skettenis "A::B::C::D::foo" as single, monolithic symbols, because
574b725ae77Skettenis A, B, C or D may be namespaces.
575b725ae77Skettenis
576b725ae77Skettenis Note that namespaces can nest only inside other
577b725ae77Skettenis namespaces, and not inside classes. So we need only
578b725ae77Skettenis consider *prefixes* of the string; there is no need to look up
579b725ae77Skettenis "B::C" separately as a symbol in the previous example. */
580b725ae77Skettenis
581b725ae77Skettenis char *p;
582b725ae77Skettenis char *start, *end;
583b725ae77Skettenis char *prefix = NULL;
584b725ae77Skettenis char *tmp;
585b725ae77Skettenis struct symbol *sym_class = NULL;
586b725ae77Skettenis struct symbol *sym_var = NULL;
587b725ae77Skettenis struct type *t;
588b725ae77Skettenis int prefix_len = 0;
589b725ae77Skettenis int done = 0;
590b725ae77Skettenis char *q;
591b725ae77Skettenis
592b725ae77Skettenis /* Check for HP-compiled executable -- in other cases
593b725ae77Skettenis return NULL, and caller must default to standard GDB
594b725ae77Skettenis behaviour. */
595b725ae77Skettenis
596*63addd46Skettenis if (!deprecated_hp_som_som_object_present)
597b725ae77Skettenis return (struct symbol *) NULL;
598b725ae77Skettenis
599b725ae77Skettenis p = name;
600b725ae77Skettenis
601b725ae77Skettenis /* Skip over whitespace and possible global "::" */
602b725ae77Skettenis while (*p && (*p == ' ' || *p == '\t'))
603b725ae77Skettenis p++;
604b725ae77Skettenis if (p[0] == ':' && p[1] == ':')
605b725ae77Skettenis p += 2;
606b725ae77Skettenis while (*p && (*p == ' ' || *p == '\t'))
607b725ae77Skettenis p++;
608b725ae77Skettenis
609b725ae77Skettenis while (1)
610b725ae77Skettenis {
611b725ae77Skettenis /* Get to the end of the next namespace or class spec. */
612b725ae77Skettenis /* If we're looking at some non-token, fail immediately */
613b725ae77Skettenis start = p;
614b725ae77Skettenis if (!(isalpha (*p) || *p == '$' || *p == '_'))
615b725ae77Skettenis return (struct symbol *) NULL;
616b725ae77Skettenis p++;
617b725ae77Skettenis while (*p && (isalnum (*p) || *p == '$' || *p == '_'))
618b725ae77Skettenis p++;
619b725ae77Skettenis
620b725ae77Skettenis if (*p == '<')
621b725ae77Skettenis {
622b725ae77Skettenis /* If we have the start of a template specification,
623b725ae77Skettenis scan right ahead to its end */
624b725ae77Skettenis q = find_template_name_end (p);
625b725ae77Skettenis if (q)
626b725ae77Skettenis p = q;
627b725ae77Skettenis }
628b725ae77Skettenis
629b725ae77Skettenis end = p;
630b725ae77Skettenis
631b725ae77Skettenis /* Skip over "::" and whitespace for next time around */
632b725ae77Skettenis while (*p && (*p == ' ' || *p == '\t'))
633b725ae77Skettenis p++;
634b725ae77Skettenis if (p[0] == ':' && p[1] == ':')
635b725ae77Skettenis p += 2;
636b725ae77Skettenis while (*p && (*p == ' ' || *p == '\t'))
637b725ae77Skettenis p++;
638b725ae77Skettenis
639b725ae77Skettenis /* Done with tokens? */
640b725ae77Skettenis if (!*p || !(isalpha (*p) || *p == '$' || *p == '_'))
641b725ae77Skettenis done = 1;
642b725ae77Skettenis
643b725ae77Skettenis tmp = (char *) alloca (prefix_len + end - start + 3);
644b725ae77Skettenis if (prefix)
645b725ae77Skettenis {
646b725ae77Skettenis memcpy (tmp, prefix, prefix_len);
647b725ae77Skettenis memcpy (tmp + prefix_len, coloncolon, 2);
648b725ae77Skettenis memcpy (tmp + prefix_len + 2, start, end - start);
649b725ae77Skettenis tmp[prefix_len + 2 + end - start] = '\000';
650b725ae77Skettenis }
651b725ae77Skettenis else
652b725ae77Skettenis {
653b725ae77Skettenis memcpy (tmp, start, end - start);
654b725ae77Skettenis tmp[end - start] = '\000';
655b725ae77Skettenis }
656b725ae77Skettenis
657b725ae77Skettenis prefix = tmp;
658b725ae77Skettenis prefix_len = strlen (prefix);
659b725ae77Skettenis
660b725ae77Skettenis /* See if the prefix we have now is something we know about */
661b725ae77Skettenis
662b725ae77Skettenis if (!done)
663b725ae77Skettenis {
664b725ae77Skettenis /* More tokens to process, so this must be a class/namespace */
665b725ae77Skettenis sym_class = lookup_symbol (prefix, 0, STRUCT_DOMAIN,
666b725ae77Skettenis 0, (struct symtab **) NULL);
667b725ae77Skettenis }
668b725ae77Skettenis else
669b725ae77Skettenis {
670b725ae77Skettenis /* No more tokens, so try as a variable first */
671b725ae77Skettenis sym_var = lookup_symbol (prefix, 0, VAR_DOMAIN,
672b725ae77Skettenis 0, (struct symtab **) NULL);
673b725ae77Skettenis /* If failed, try as class/namespace */
674b725ae77Skettenis if (!sym_var)
675b725ae77Skettenis sym_class = lookup_symbol (prefix, 0, STRUCT_DOMAIN,
676b725ae77Skettenis 0, (struct symtab **) NULL);
677b725ae77Skettenis }
678b725ae77Skettenis
679b725ae77Skettenis if (sym_var ||
680b725ae77Skettenis (sym_class &&
681b725ae77Skettenis (t = check_typedef (SYMBOL_TYPE (sym_class)),
682b725ae77Skettenis (TYPE_CODE (t) == TYPE_CODE_STRUCT
683b725ae77Skettenis || TYPE_CODE (t) == TYPE_CODE_UNION))))
684b725ae77Skettenis {
685b725ae77Skettenis /* We found a valid token */
686b725ae77Skettenis *token = (char *) xmalloc (prefix_len + 1);
687b725ae77Skettenis memcpy (*token, prefix, prefix_len);
688b725ae77Skettenis (*token)[prefix_len] = '\000';
689b725ae77Skettenis break;
690b725ae77Skettenis }
691b725ae77Skettenis
692b725ae77Skettenis /* No variable or class/namespace found, no more tokens */
693b725ae77Skettenis if (done)
694b725ae77Skettenis return (struct symbol *) NULL;
695b725ae77Skettenis }
696b725ae77Skettenis
697b725ae77Skettenis /* Out of loop, so we must have found a valid token */
698b725ae77Skettenis if (sym_var)
699b725ae77Skettenis *class_prefix = 0;
700b725ae77Skettenis else
701b725ae77Skettenis *class_prefix = 1;
702b725ae77Skettenis
703b725ae77Skettenis if (argptr)
704b725ae77Skettenis *argptr = done ? p : end;
705b725ae77Skettenis
706b725ae77Skettenis return sym_var ? sym_var : sym_class; /* found */
707b725ae77Skettenis }
708b725ae77Skettenis
709b725ae77Skettenis char *
find_template_name_end(char * p)710b725ae77Skettenis find_template_name_end (char *p)
711b725ae77Skettenis {
712b725ae77Skettenis int depth = 1;
713b725ae77Skettenis int just_seen_right = 0;
714b725ae77Skettenis int just_seen_colon = 0;
715b725ae77Skettenis int just_seen_space = 0;
716b725ae77Skettenis
717b725ae77Skettenis if (!p || (*p != '<'))
718b725ae77Skettenis return 0;
719b725ae77Skettenis
720b725ae77Skettenis while (*++p)
721b725ae77Skettenis {
722b725ae77Skettenis switch (*p)
723b725ae77Skettenis {
724b725ae77Skettenis case '\'':
725b725ae77Skettenis case '\"':
726b725ae77Skettenis case '{':
727b725ae77Skettenis case '}':
728b725ae77Skettenis /* In future, may want to allow these?? */
729b725ae77Skettenis return 0;
730b725ae77Skettenis case '<':
731b725ae77Skettenis depth++; /* start nested template */
732b725ae77Skettenis if (just_seen_colon || just_seen_right || just_seen_space)
733b725ae77Skettenis return 0; /* but not after : or :: or > or space */
734b725ae77Skettenis break;
735b725ae77Skettenis case '>':
736b725ae77Skettenis if (just_seen_colon || just_seen_right)
737b725ae77Skettenis return 0; /* end a (nested?) template */
738b725ae77Skettenis just_seen_right = 1; /* but not after : or :: */
739b725ae77Skettenis if (--depth == 0) /* also disallow >>, insist on > > */
740b725ae77Skettenis return ++p; /* if outermost ended, return */
741b725ae77Skettenis break;
742b725ae77Skettenis case ':':
743b725ae77Skettenis if (just_seen_space || (just_seen_colon > 1))
744b725ae77Skettenis return 0; /* nested class spec coming up */
745b725ae77Skettenis just_seen_colon++; /* we allow :: but not :::: */
746b725ae77Skettenis break;
747b725ae77Skettenis case ' ':
748b725ae77Skettenis break;
749b725ae77Skettenis default:
750b725ae77Skettenis if (!((*p >= 'a' && *p <= 'z') || /* allow token chars */
751b725ae77Skettenis (*p >= 'A' && *p <= 'Z') ||
752b725ae77Skettenis (*p >= '0' && *p <= '9') ||
753b725ae77Skettenis (*p == '_') || (*p == ',') || /* commas for template args */
754b725ae77Skettenis (*p == '&') || (*p == '*') || /* pointer and ref types */
755b725ae77Skettenis (*p == '(') || (*p == ')') || /* function types */
756b725ae77Skettenis (*p == '[') || (*p == ']'))) /* array types */
757b725ae77Skettenis return 0;
758b725ae77Skettenis }
759b725ae77Skettenis if (*p != ' ')
760b725ae77Skettenis just_seen_space = 0;
761b725ae77Skettenis if (*p != ':')
762b725ae77Skettenis just_seen_colon = 0;
763b725ae77Skettenis if (*p != '>')
764b725ae77Skettenis just_seen_right = 0;
765b725ae77Skettenis }
766b725ae77Skettenis return 0;
767b725ae77Skettenis }
768e93f7393Sniklas
769b725ae77Skettenis
770b725ae77Skettenis
771e93f7393Sniklas /* Return a null-terminated temporary copy of the name
772e93f7393Sniklas of a string token. */
773e93f7393Sniklas
774e93f7393Sniklas char *
copy_name(struct stoken token)775b725ae77Skettenis copy_name (struct stoken token)
776e93f7393Sniklas {
777e93f7393Sniklas memcpy (namecopy, token.ptr, token.length);
778e93f7393Sniklas namecopy[token.length] = 0;
779e93f7393Sniklas return namecopy;
780e93f7393Sniklas }
781e93f7393Sniklas
782e93f7393Sniklas /* Reverse an expression from suffix form (in which it is constructed)
783e93f7393Sniklas to prefix form (in which we can conveniently print or execute it). */
784e93f7393Sniklas
785e93f7393Sniklas static void
prefixify_expression(struct expression * expr)786b725ae77Skettenis prefixify_expression (struct expression *expr)
787e93f7393Sniklas {
788b725ae77Skettenis int len =
789e93f7393Sniklas sizeof (struct expression) + EXP_ELEM_TO_BYTES (expr->nelts);
790b725ae77Skettenis struct expression *temp;
791b725ae77Skettenis int inpos = expr->nelts, outpos = 0;
792e93f7393Sniklas
793e93f7393Sniklas temp = (struct expression *) alloca (len);
794e93f7393Sniklas
795e93f7393Sniklas /* Copy the original expression into temp. */
796e93f7393Sniklas memcpy (temp, expr, len);
797e93f7393Sniklas
798e93f7393Sniklas prefixify_subexp (temp, expr, inpos, outpos);
799e93f7393Sniklas }
800e93f7393Sniklas
801b725ae77Skettenis /* Return the number of exp_elements in the postfix subexpression
802b725ae77Skettenis of EXPR whose operator is at index ENDPOS - 1 in EXPR. */
803e93f7393Sniklas
804b725ae77Skettenis int
length_of_subexp(struct expression * expr,int endpos)805b725ae77Skettenis length_of_subexp (struct expression *expr, int endpos)
806e93f7393Sniklas {
807b725ae77Skettenis int oplen, args, i;
808b725ae77Skettenis
809b725ae77Skettenis operator_length (expr, endpos, &oplen, &args);
810b725ae77Skettenis
811b725ae77Skettenis while (args > 0)
812b725ae77Skettenis {
813b725ae77Skettenis oplen += length_of_subexp (expr, endpos - oplen);
814b725ae77Skettenis args--;
815b725ae77Skettenis }
816b725ae77Skettenis
817b725ae77Skettenis return oplen;
818b725ae77Skettenis }
819b725ae77Skettenis
820b725ae77Skettenis /* Sets *OPLENP to the length of the operator whose (last) index is
821b725ae77Skettenis ENDPOS - 1 in EXPR, and sets *ARGSP to the number of arguments that
822b725ae77Skettenis operator takes. */
823b725ae77Skettenis
824b725ae77Skettenis void
operator_length(struct expression * expr,int endpos,int * oplenp,int * argsp)825b725ae77Skettenis operator_length (struct expression *expr, int endpos, int *oplenp, int *argsp)
826b725ae77Skettenis {
827b725ae77Skettenis expr->language_defn->la_exp_desc->operator_length (expr, endpos,
828b725ae77Skettenis oplenp, argsp);
829b725ae77Skettenis }
830b725ae77Skettenis
831b725ae77Skettenis /* Default value for operator_length in exp_descriptor vectors. */
832b725ae77Skettenis
833b725ae77Skettenis void
operator_length_standard(struct expression * expr,int endpos,int * oplenp,int * argsp)834b725ae77Skettenis operator_length_standard (struct expression *expr, int endpos,
835b725ae77Skettenis int *oplenp, int *argsp)
836b725ae77Skettenis {
837b725ae77Skettenis int oplen = 1;
838b725ae77Skettenis int args = 0;
839b725ae77Skettenis int i;
840e93f7393Sniklas
841e93f7393Sniklas if (endpos < 1)
842b725ae77Skettenis error ("?error in operator_length_standard");
843e93f7393Sniklas
844e93f7393Sniklas i = (int) expr->elts[endpos - 1].opcode;
845e93f7393Sniklas
846e93f7393Sniklas switch (i)
847e93f7393Sniklas {
848e93f7393Sniklas /* C++ */
849e93f7393Sniklas case OP_SCOPE:
850e93f7393Sniklas oplen = longest_to_int (expr->elts[endpos - 2].longconst);
851e93f7393Sniklas oplen = 5 + BYTES_TO_EXP_ELEM (oplen + 1);
852e93f7393Sniklas break;
853e93f7393Sniklas
854e93f7393Sniklas case OP_LONG:
855e93f7393Sniklas case OP_DOUBLE:
856e93f7393Sniklas case OP_VAR_VALUE:
857e93f7393Sniklas oplen = 4;
858e93f7393Sniklas break;
859e93f7393Sniklas
860e93f7393Sniklas case OP_TYPE:
861e93f7393Sniklas case OP_BOOL:
862e93f7393Sniklas case OP_LAST:
863e93f7393Sniklas case OP_REGISTER:
864e93f7393Sniklas case OP_INTERNALVAR:
865e93f7393Sniklas oplen = 3;
866e93f7393Sniklas break;
867e93f7393Sniklas
868e93f7393Sniklas case OP_COMPLEX:
869e93f7393Sniklas oplen = 1;
870e93f7393Sniklas args = 2;
871e93f7393Sniklas break;
872e93f7393Sniklas
873e93f7393Sniklas case OP_FUNCALL:
874e93f7393Sniklas case OP_F77_UNDETERMINED_ARGLIST:
875e93f7393Sniklas oplen = 3;
876e93f7393Sniklas args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
877e93f7393Sniklas break;
878e93f7393Sniklas
879b725ae77Skettenis case OP_OBJC_MSGCALL: /* Objective C message (method) call */
880b725ae77Skettenis oplen = 4;
881b725ae77Skettenis args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
882b725ae77Skettenis break;
883b725ae77Skettenis
884e93f7393Sniklas case UNOP_MAX:
885e93f7393Sniklas case UNOP_MIN:
886e93f7393Sniklas oplen = 3;
887e93f7393Sniklas break;
888e93f7393Sniklas
889e93f7393Sniklas case BINOP_VAL:
890e93f7393Sniklas case UNOP_CAST:
891e93f7393Sniklas case UNOP_MEMVAL:
892e93f7393Sniklas oplen = 3;
893e93f7393Sniklas args = 1;
894e93f7393Sniklas break;
895e93f7393Sniklas
896e93f7393Sniklas case UNOP_ABS:
897e93f7393Sniklas case UNOP_CAP:
898e93f7393Sniklas case UNOP_CHR:
899e93f7393Sniklas case UNOP_FLOAT:
900e93f7393Sniklas case UNOP_HIGH:
901e93f7393Sniklas case UNOP_ODD:
902e93f7393Sniklas case UNOP_ORD:
903e93f7393Sniklas case UNOP_TRUNC:
904e93f7393Sniklas oplen = 1;
905e93f7393Sniklas args = 1;
906e93f7393Sniklas break;
907e93f7393Sniklas
908e93f7393Sniklas case OP_LABELED:
909e93f7393Sniklas case STRUCTOP_STRUCT:
910e93f7393Sniklas case STRUCTOP_PTR:
911e93f7393Sniklas args = 1;
912e93f7393Sniklas /* fall through */
913e93f7393Sniklas case OP_M2_STRING:
914e93f7393Sniklas case OP_STRING:
915b725ae77Skettenis case OP_OBJC_NSSTRING: /* Objective C Foundation Class NSString constant */
916b725ae77Skettenis case OP_OBJC_SELECTOR: /* Objective C "@selector" pseudo-op */
917e93f7393Sniklas case OP_NAME:
918e93f7393Sniklas case OP_EXPRSTRING:
919e93f7393Sniklas oplen = longest_to_int (expr->elts[endpos - 2].longconst);
920e93f7393Sniklas oplen = 4 + BYTES_TO_EXP_ELEM (oplen + 1);
921e93f7393Sniklas break;
922e93f7393Sniklas
923e93f7393Sniklas case OP_BITSTRING:
924e93f7393Sniklas oplen = longest_to_int (expr->elts[endpos - 2].longconst);
925e93f7393Sniklas oplen = (oplen + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
926e93f7393Sniklas oplen = 4 + BYTES_TO_EXP_ELEM (oplen);
927e93f7393Sniklas break;
928e93f7393Sniklas
929e93f7393Sniklas case OP_ARRAY:
930e93f7393Sniklas oplen = 4;
931e93f7393Sniklas args = longest_to_int (expr->elts[endpos - 2].longconst);
932e93f7393Sniklas args -= longest_to_int (expr->elts[endpos - 3].longconst);
933e93f7393Sniklas args += 1;
934e93f7393Sniklas break;
935e93f7393Sniklas
936e93f7393Sniklas case TERNOP_COND:
937e93f7393Sniklas case TERNOP_SLICE:
938e93f7393Sniklas case TERNOP_SLICE_COUNT:
939e93f7393Sniklas args = 3;
940e93f7393Sniklas break;
941e93f7393Sniklas
942e93f7393Sniklas /* Modula-2 */
943e93f7393Sniklas case MULTI_SUBSCRIPT:
944e93f7393Sniklas oplen = 3;
945e93f7393Sniklas args = 1 + longest_to_int (expr->elts[endpos - 2].longconst);
946e93f7393Sniklas break;
947e93f7393Sniklas
948e93f7393Sniklas case BINOP_ASSIGN_MODIFY:
949e93f7393Sniklas oplen = 3;
950e93f7393Sniklas args = 2;
951e93f7393Sniklas break;
952e93f7393Sniklas
953e93f7393Sniklas /* C++ */
954e93f7393Sniklas case OP_THIS:
955b725ae77Skettenis case OP_OBJC_SELF:
956e93f7393Sniklas oplen = 2;
957e93f7393Sniklas break;
958e93f7393Sniklas
959e93f7393Sniklas default:
960e93f7393Sniklas args = 1 + (i < (int) BINOP_END);
961e93f7393Sniklas }
962e93f7393Sniklas
963b725ae77Skettenis *oplenp = oplen;
964b725ae77Skettenis *argsp = args;
965e93f7393Sniklas }
966e93f7393Sniklas
967e93f7393Sniklas /* Copy the subexpression ending just before index INEND in INEXPR
968e93f7393Sniklas into OUTEXPR, starting at index OUTBEG.
969e93f7393Sniklas In the process, convert it from suffix to prefix form. */
970e93f7393Sniklas
971e93f7393Sniklas static void
prefixify_subexp(struct expression * inexpr,struct expression * outexpr,int inend,int outbeg)972b725ae77Skettenis prefixify_subexp (struct expression *inexpr,
973b725ae77Skettenis struct expression *outexpr, int inend, int outbeg)
974e93f7393Sniklas {
975b725ae77Skettenis int oplen;
976b725ae77Skettenis int args;
977b725ae77Skettenis int i;
978e93f7393Sniklas int *arglens;
979e93f7393Sniklas enum exp_opcode opcode;
980e93f7393Sniklas
981b725ae77Skettenis operator_length (inexpr, inend, &oplen, &args);
982e93f7393Sniklas
983e93f7393Sniklas /* Copy the final operator itself, from the end of the input
984e93f7393Sniklas to the beginning of the output. */
985e93f7393Sniklas inend -= oplen;
986e93f7393Sniklas memcpy (&outexpr->elts[outbeg], &inexpr->elts[inend],
987e93f7393Sniklas EXP_ELEM_TO_BYTES (oplen));
988e93f7393Sniklas outbeg += oplen;
989e93f7393Sniklas
990e93f7393Sniklas /* Find the lengths of the arg subexpressions. */
991e93f7393Sniklas arglens = (int *) alloca (args * sizeof (int));
992e93f7393Sniklas for (i = args - 1; i >= 0; i--)
993e93f7393Sniklas {
994e93f7393Sniklas oplen = length_of_subexp (inexpr, inend);
995e93f7393Sniklas arglens[i] = oplen;
996e93f7393Sniklas inend -= oplen;
997e93f7393Sniklas }
998e93f7393Sniklas
999e93f7393Sniklas /* Now copy each subexpression, preserving the order of
1000e93f7393Sniklas the subexpressions, but prefixifying each one.
1001e93f7393Sniklas In this loop, inend starts at the beginning of
1002e93f7393Sniklas the expression this level is working on
1003e93f7393Sniklas and marches forward over the arguments.
1004e93f7393Sniklas outbeg does similarly in the output. */
1005e93f7393Sniklas for (i = 0; i < args; i++)
1006e93f7393Sniklas {
1007e93f7393Sniklas oplen = arglens[i];
1008e93f7393Sniklas inend += oplen;
1009e93f7393Sniklas prefixify_subexp (inexpr, outexpr, inend, outbeg);
1010e93f7393Sniklas outbeg += oplen;
1011e93f7393Sniklas }
1012e93f7393Sniklas }
1013e93f7393Sniklas
1014e93f7393Sniklas /* This page contains the two entry points to this file. */
1015e93f7393Sniklas
1016e93f7393Sniklas /* Read an expression from the string *STRINGPTR points to,
1017e93f7393Sniklas parse it, and return a pointer to a struct expression that we malloc.
1018e93f7393Sniklas Use block BLOCK as the lexical context for variable names;
1019e93f7393Sniklas if BLOCK is zero, use the block of the selected stack frame.
1020e93f7393Sniklas Meanwhile, advance *STRINGPTR to point after the expression,
1021e93f7393Sniklas at the first nonwhite character that is not part of the expression
1022e93f7393Sniklas (possibly a null character).
1023e93f7393Sniklas
1024e93f7393Sniklas If COMMA is nonzero, stop if a comma is reached. */
1025e93f7393Sniklas
1026e93f7393Sniklas struct expression *
parse_exp_1(char ** stringptr,struct block * block,int comma)1027b725ae77Skettenis parse_exp_1 (char **stringptr, struct block *block, int comma)
1028e93f7393Sniklas {
1029*63addd46Skettenis return parse_exp_in_context (stringptr, block, comma, 0);
1030*63addd46Skettenis }
1031*63addd46Skettenis
1032*63addd46Skettenis /* As for parse_exp_1, except that if VOID_CONTEXT_P, then
1033*63addd46Skettenis no value is expected from the expression. */
1034*63addd46Skettenis
1035*63addd46Skettenis static struct expression *
parse_exp_in_context(char ** stringptr,struct block * block,int comma,int void_context_p)1036*63addd46Skettenis parse_exp_in_context (char **stringptr, struct block *block, int comma,
1037*63addd46Skettenis int void_context_p)
1038*63addd46Skettenis {
1039e93f7393Sniklas struct cleanup *old_chain;
1040e93f7393Sniklas
1041e93f7393Sniklas lexptr = *stringptr;
1042b725ae77Skettenis prev_lexptr = NULL;
1043e93f7393Sniklas
1044e93f7393Sniklas paren_depth = 0;
1045e93f7393Sniklas type_stack_depth = 0;
1046e93f7393Sniklas
1047e93f7393Sniklas comma_terminates = comma;
1048e93f7393Sniklas
1049e93f7393Sniklas if (lexptr == 0 || *lexptr == 0)
1050e93f7393Sniklas error_no_arg ("expression to compute");
1051e93f7393Sniklas
1052b725ae77Skettenis old_chain = make_cleanup (free_funcalls, 0 /*ignore*/);
1053e93f7393Sniklas funcall_chain = 0;
1054e93f7393Sniklas
1055b725ae77Skettenis if (block)
1056b725ae77Skettenis {
1057b725ae77Skettenis expression_context_block = block;
1058b725ae77Skettenis expression_context_pc = BLOCK_START (block);
1059b725ae77Skettenis }
1060b725ae77Skettenis else
1061b725ae77Skettenis expression_context_block = get_selected_block (&expression_context_pc);
1062e93f7393Sniklas
1063e93f7393Sniklas namecopy = (char *) alloca (strlen (lexptr) + 1);
1064e93f7393Sniklas expout_size = 10;
1065e93f7393Sniklas expout_ptr = 0;
1066e93f7393Sniklas expout = (struct expression *)
1067e93f7393Sniklas xmalloc (sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_size));
1068e93f7393Sniklas expout->language_defn = current_language;
1069e93f7393Sniklas make_cleanup (free_current_contents, &expout);
1070e93f7393Sniklas
1071e93f7393Sniklas if (current_language->la_parser ())
1072e93f7393Sniklas current_language->la_error (NULL);
1073e93f7393Sniklas
1074e93f7393Sniklas discard_cleanups (old_chain);
1075e93f7393Sniklas
1076e93f7393Sniklas /* Record the actual number of expression elements, and then
1077e93f7393Sniklas reallocate the expression memory so that we free up any
1078e93f7393Sniklas excess elements. */
1079e93f7393Sniklas
1080e93f7393Sniklas expout->nelts = expout_ptr;
1081e93f7393Sniklas expout = (struct expression *)
1082e93f7393Sniklas xrealloc ((char *) expout,
1083e93f7393Sniklas sizeof (struct expression) + EXP_ELEM_TO_BYTES (expout_ptr));;
1084e93f7393Sniklas
1085e93f7393Sniklas /* Convert expression from postfix form as generated by yacc
1086e93f7393Sniklas parser, to a prefix form. */
1087e93f7393Sniklas
1088b725ae77Skettenis if (expressiondebug)
1089b725ae77Skettenis dump_raw_expression (expout, gdb_stdlog,
1090b725ae77Skettenis "before conversion to prefix form");
1091b725ae77Skettenis
1092e93f7393Sniklas prefixify_expression (expout);
1093b725ae77Skettenis
1094*63addd46Skettenis current_language->la_post_parser (&expout, void_context_p);
1095*63addd46Skettenis
1096b725ae77Skettenis if (expressiondebug)
1097b725ae77Skettenis dump_prefix_expression (expout, gdb_stdlog);
1098e93f7393Sniklas
1099e93f7393Sniklas *stringptr = lexptr;
1100e93f7393Sniklas return expout;
1101e93f7393Sniklas }
1102e93f7393Sniklas
1103e93f7393Sniklas /* Parse STRING as an expression, and complain if this fails
1104e93f7393Sniklas to use up all of the contents of STRING. */
1105e93f7393Sniklas
1106e93f7393Sniklas struct expression *
parse_expression(char * string)1107b725ae77Skettenis parse_expression (char *string)
1108e93f7393Sniklas {
1109b725ae77Skettenis struct expression *exp;
1110e93f7393Sniklas exp = parse_exp_1 (&string, 0, 0);
1111e93f7393Sniklas if (*string)
1112e93f7393Sniklas error ("Junk after end of expression.");
1113e93f7393Sniklas return exp;
1114e93f7393Sniklas }
1115*63addd46Skettenis
1116*63addd46Skettenis
1117*63addd46Skettenis /* As for parse_expression, except that if VOID_CONTEXT_P, then
1118*63addd46Skettenis no value is expected from the expression. */
1119*63addd46Skettenis
1120*63addd46Skettenis struct expression *
parse_expression_in_context(char * string,int void_context_p)1121*63addd46Skettenis parse_expression_in_context (char *string, int void_context_p)
1122*63addd46Skettenis {
1123*63addd46Skettenis struct expression *exp;
1124*63addd46Skettenis exp = parse_exp_in_context (&string, 0, 0, void_context_p);
1125*63addd46Skettenis if (*string != '\000')
1126*63addd46Skettenis error ("Junk after end of expression.");
1127*63addd46Skettenis return exp;
1128*63addd46Skettenis }
1129*63addd46Skettenis
1130*63addd46Skettenis /* A post-parser that does nothing */
1131*63addd46Skettenis
1132*63addd46Skettenis void
null_post_parser(struct expression ** exp,int void_context_p)1133*63addd46Skettenis null_post_parser (struct expression **exp, int void_context_p)
1134*63addd46Skettenis {
1135*63addd46Skettenis }
1136e93f7393Sniklas
1137e93f7393Sniklas /* Stuff for maintaining a stack of types. Currently just used by C, but
1138e93f7393Sniklas probably useful for any language which declares its types "backwards". */
1139e93f7393Sniklas
1140b725ae77Skettenis static void
check_type_stack_depth(void)1141b725ae77Skettenis check_type_stack_depth (void)
1142e93f7393Sniklas {
1143e93f7393Sniklas if (type_stack_depth == type_stack_size)
1144e93f7393Sniklas {
1145e93f7393Sniklas type_stack_size *= 2;
1146e93f7393Sniklas type_stack = (union type_stack_elt *)
1147e93f7393Sniklas xrealloc ((char *) type_stack, type_stack_size * sizeof (*type_stack));
1148e93f7393Sniklas }
1149b725ae77Skettenis }
1150b725ae77Skettenis
1151b725ae77Skettenis void
push_type(enum type_pieces tp)1152b725ae77Skettenis push_type (enum type_pieces tp)
1153b725ae77Skettenis {
1154b725ae77Skettenis check_type_stack_depth ();
1155e93f7393Sniklas type_stack[type_stack_depth++].piece = tp;
1156e93f7393Sniklas }
1157e93f7393Sniklas
1158e93f7393Sniklas void
push_type_int(int n)1159b725ae77Skettenis push_type_int (int n)
1160e93f7393Sniklas {
1161b725ae77Skettenis check_type_stack_depth ();
1162e93f7393Sniklas type_stack[type_stack_depth++].int_val = n;
1163e93f7393Sniklas }
1164e93f7393Sniklas
1165b725ae77Skettenis void
push_type_address_space(char * string)1166b725ae77Skettenis push_type_address_space (char *string)
1167b725ae77Skettenis {
1168b725ae77Skettenis push_type_int (address_space_name_to_int (string));
1169b725ae77Skettenis }
1170b725ae77Skettenis
1171e93f7393Sniklas enum type_pieces
pop_type(void)1172b725ae77Skettenis pop_type (void)
1173e93f7393Sniklas {
1174e93f7393Sniklas if (type_stack_depth)
1175e93f7393Sniklas return type_stack[--type_stack_depth].piece;
1176e93f7393Sniklas return tp_end;
1177e93f7393Sniklas }
1178e93f7393Sniklas
1179e93f7393Sniklas int
pop_type_int(void)1180b725ae77Skettenis pop_type_int (void)
1181e93f7393Sniklas {
1182e93f7393Sniklas if (type_stack_depth)
1183e93f7393Sniklas return type_stack[--type_stack_depth].int_val;
1184e93f7393Sniklas /* "Can't happen". */
1185e93f7393Sniklas return 0;
1186e93f7393Sniklas }
1187e93f7393Sniklas
1188e93f7393Sniklas /* Pop the type stack and return the type which corresponds to FOLLOW_TYPE
1189e93f7393Sniklas as modified by all the stuff on the stack. */
1190e93f7393Sniklas struct type *
follow_types(struct type * follow_type)1191b725ae77Skettenis follow_types (struct type *follow_type)
1192e93f7393Sniklas {
1193e93f7393Sniklas int done = 0;
1194b725ae77Skettenis int make_const = 0;
1195b725ae77Skettenis int make_volatile = 0;
1196b725ae77Skettenis int make_addr_space = 0;
1197e93f7393Sniklas int array_size;
1198e93f7393Sniklas struct type *range_type;
1199e93f7393Sniklas
1200e93f7393Sniklas while (!done)
1201e93f7393Sniklas switch (pop_type ())
1202e93f7393Sniklas {
1203e93f7393Sniklas case tp_end:
1204e93f7393Sniklas done = 1;
1205b725ae77Skettenis if (make_const)
1206b725ae77Skettenis follow_type = make_cv_type (make_const,
1207b725ae77Skettenis TYPE_VOLATILE (follow_type),
1208b725ae77Skettenis follow_type, 0);
1209b725ae77Skettenis if (make_volatile)
1210b725ae77Skettenis follow_type = make_cv_type (TYPE_CONST (follow_type),
1211b725ae77Skettenis make_volatile,
1212b725ae77Skettenis follow_type, 0);
1213b725ae77Skettenis if (make_addr_space)
1214b725ae77Skettenis follow_type = make_type_with_address_space (follow_type,
1215b725ae77Skettenis make_addr_space);
1216b725ae77Skettenis make_const = make_volatile = 0;
1217b725ae77Skettenis make_addr_space = 0;
1218b725ae77Skettenis break;
1219b725ae77Skettenis case tp_const:
1220b725ae77Skettenis make_const = 1;
1221b725ae77Skettenis break;
1222b725ae77Skettenis case tp_volatile:
1223b725ae77Skettenis make_volatile = 1;
1224b725ae77Skettenis break;
1225b725ae77Skettenis case tp_space_identifier:
1226b725ae77Skettenis make_addr_space = pop_type_int ();
1227e93f7393Sniklas break;
1228e93f7393Sniklas case tp_pointer:
1229e93f7393Sniklas follow_type = lookup_pointer_type (follow_type);
1230b725ae77Skettenis if (make_const)
1231b725ae77Skettenis follow_type = make_cv_type (make_const,
1232b725ae77Skettenis TYPE_VOLATILE (follow_type),
1233b725ae77Skettenis follow_type, 0);
1234b725ae77Skettenis if (make_volatile)
1235b725ae77Skettenis follow_type = make_cv_type (TYPE_CONST (follow_type),
1236b725ae77Skettenis make_volatile,
1237b725ae77Skettenis follow_type, 0);
1238b725ae77Skettenis if (make_addr_space)
1239b725ae77Skettenis follow_type = make_type_with_address_space (follow_type,
1240b725ae77Skettenis make_addr_space);
1241b725ae77Skettenis make_const = make_volatile = 0;
1242b725ae77Skettenis make_addr_space = 0;
1243e93f7393Sniklas break;
1244e93f7393Sniklas case tp_reference:
1245e93f7393Sniklas follow_type = lookup_reference_type (follow_type);
1246b725ae77Skettenis if (make_const)
1247b725ae77Skettenis follow_type = make_cv_type (make_const,
1248b725ae77Skettenis TYPE_VOLATILE (follow_type),
1249b725ae77Skettenis follow_type, 0);
1250b725ae77Skettenis if (make_volatile)
1251b725ae77Skettenis follow_type = make_cv_type (TYPE_CONST (follow_type),
1252b725ae77Skettenis make_volatile,
1253b725ae77Skettenis follow_type, 0);
1254b725ae77Skettenis if (make_addr_space)
1255b725ae77Skettenis follow_type = make_type_with_address_space (follow_type,
1256b725ae77Skettenis make_addr_space);
1257b725ae77Skettenis make_const = make_volatile = 0;
1258b725ae77Skettenis make_addr_space = 0;
1259e93f7393Sniklas break;
1260e93f7393Sniklas case tp_array:
1261e93f7393Sniklas array_size = pop_type_int ();
1262e93f7393Sniklas /* FIXME-type-allocation: need a way to free this type when we are
1263e93f7393Sniklas done with it. */
1264e93f7393Sniklas range_type =
1265e93f7393Sniklas create_range_type ((struct type *) NULL,
1266e93f7393Sniklas builtin_type_int, 0,
1267e93f7393Sniklas array_size >= 0 ? array_size - 1 : 0);
1268e93f7393Sniklas follow_type =
1269e93f7393Sniklas create_array_type ((struct type *) NULL,
1270e93f7393Sniklas follow_type, range_type);
1271e93f7393Sniklas if (array_size < 0)
1272e93f7393Sniklas TYPE_ARRAY_UPPER_BOUND_TYPE (follow_type)
1273e93f7393Sniklas = BOUND_CANNOT_BE_DETERMINED;
1274e93f7393Sniklas break;
1275e93f7393Sniklas case tp_function:
1276e93f7393Sniklas /* FIXME-type-allocation: need a way to free this type when we are
1277e93f7393Sniklas done with it. */
1278e93f7393Sniklas follow_type = lookup_function_type (follow_type);
1279e93f7393Sniklas break;
1280e93f7393Sniklas }
1281e93f7393Sniklas return follow_type;
1282e93f7393Sniklas }
1283e93f7393Sniklas
1284b725ae77Skettenis static void build_parse (void);
1285b725ae77Skettenis static void
build_parse(void)1286b725ae77Skettenis build_parse (void)
1287e93f7393Sniklas {
1288b725ae77Skettenis int i;
1289e93f7393Sniklas
1290e93f7393Sniklas msym_text_symbol_type =
1291e93f7393Sniklas init_type (TYPE_CODE_FUNC, 1, 0, "<text variable, no debug info>", NULL);
1292e93f7393Sniklas TYPE_TARGET_TYPE (msym_text_symbol_type) = builtin_type_int;
1293e93f7393Sniklas msym_data_symbol_type =
1294e93f7393Sniklas init_type (TYPE_CODE_INT, TARGET_INT_BIT / HOST_CHAR_BIT, 0,
1295e93f7393Sniklas "<data variable, no debug info>", NULL);
1296e93f7393Sniklas msym_unknown_symbol_type =
1297e93f7393Sniklas init_type (TYPE_CODE_INT, 1, 0,
1298e93f7393Sniklas "<variable (not text or data), no debug info>",
1299e93f7393Sniklas NULL);
1300e93f7393Sniklas }
1301b725ae77Skettenis
1302b725ae77Skettenis /* This function avoids direct calls to fprintf
1303b725ae77Skettenis in the parser generated debug code. */
1304b725ae77Skettenis void
parser_fprintf(FILE * x,const char * y,...)1305b725ae77Skettenis parser_fprintf (FILE *x, const char *y, ...)
1306b725ae77Skettenis {
1307b725ae77Skettenis va_list args;
1308b725ae77Skettenis va_start (args, y);
1309b725ae77Skettenis if (x == stderr)
1310b725ae77Skettenis vfprintf_unfiltered (gdb_stderr, y, args);
1311b725ae77Skettenis else
1312b725ae77Skettenis {
1313b725ae77Skettenis fprintf_unfiltered (gdb_stderr, " Unknown FILE used.\n");
1314b725ae77Skettenis vfprintf_unfiltered (gdb_stderr, y, args);
1315b725ae77Skettenis }
1316b725ae77Skettenis va_end (args);
1317b725ae77Skettenis }
1318b725ae77Skettenis
1319b725ae77Skettenis void
_initialize_parse(void)1320b725ae77Skettenis _initialize_parse (void)
1321b725ae77Skettenis {
1322b725ae77Skettenis type_stack_size = 80;
1323b725ae77Skettenis type_stack_depth = 0;
1324b725ae77Skettenis type_stack = (union type_stack_elt *)
1325b725ae77Skettenis xmalloc (type_stack_size * sizeof (*type_stack));
1326b725ae77Skettenis
1327b725ae77Skettenis build_parse ();
1328b725ae77Skettenis
1329b725ae77Skettenis /* FIXME - For the moment, handle types by swapping them in and out.
1330b725ae77Skettenis Should be using the per-architecture data-pointer and a large
1331b725ae77Skettenis struct. */
1332b725ae77Skettenis DEPRECATED_REGISTER_GDBARCH_SWAP (msym_text_symbol_type);
1333b725ae77Skettenis DEPRECATED_REGISTER_GDBARCH_SWAP (msym_data_symbol_type);
1334b725ae77Skettenis DEPRECATED_REGISTER_GDBARCH_SWAP (msym_unknown_symbol_type);
1335b725ae77Skettenis deprecated_register_gdbarch_swap (NULL, 0, build_parse);
1336b725ae77Skettenis
1337*63addd46Skettenis deprecated_add_show_from_set
1338*63addd46Skettenis (add_set_cmd ("expression", class_maintenance, var_zinteger,
1339b725ae77Skettenis (char *) &expressiondebug,
1340b725ae77Skettenis "Set expression debugging.\n\
1341b725ae77Skettenis When non-zero, the internal representation of expressions will be printed.",
1342b725ae77Skettenis &setdebuglist),
1343b725ae77Skettenis &showdebuglist);
1344b725ae77Skettenis }
1345